@@ -1273,9 +1273,7 @@ def precipitation_per_day(self):
12731273 List with total precipitation for each day in the dataset.
12741274 """
12751275 return [
1276- sum (
1277- [day_dict [hour ]["total_precipitation" ] for hour in day_dict .keys ()]
1278- ) # pylint: disable=consider-using-generator
1276+ sum (day_dict [hour ]["total_precipitation" ] for hour in day_dict .keys ())
12791277 for day_dict in self .converted_surface_data .values ()
12801278 ]
12811279
@@ -2583,15 +2581,8 @@ def max_average_temperature_at_altitude(self):
25832581 Maximum average temperature.
25842582 """
25852583 max_temp = float ("-inf" )
2586- for (
2587- hour
2588- ) in (
2589- self .average_temperature_profile_by_hour .keys ()
2590- ): # pylint: disable=consider-iterating-dictionary,consider-using-dict-items
2591- max_temp = max (
2592- max_temp ,
2593- np .max (self .average_temperature_profile_by_hour [hour ][0 ]),
2594- )
2584+ for temp_profile in self .average_temperature_profile_by_hour .values ():
2585+ max_temp = max (max_temp , np .max (temp_profile [0 ]))
25952586 return max_temp
25962587
25972588 @cached_property
@@ -2607,15 +2598,8 @@ def min_average_temperature_at_altitude(self):
26072598 Minimum average temperature.
26082599 """
26092600 min_temp = float ("inf" )
2610- for (
2611- hour
2612- ) in (
2613- self .average_temperature_profile_by_hour .keys ()
2614- ): # pylint: disable=consider-iterating-dictionary,consider-using-dict-items
2615- min_temp = min (
2616- min_temp ,
2617- np .min (self .average_temperature_profile_by_hour [hour ][0 ]),
2618- )
2601+ for temp_profile in self .average_temperature_profile_by_hour .values ():
2602+ min_temp = min (min_temp , np .min (temp_profile [0 ]))
26192603 return min_temp
26202604
26212605 @cached_property
@@ -2632,15 +2616,8 @@ def max_average_wind_speed_at_altitude(self):
26322616 Maximum average wind speed.
26332617 """
26342618 max_wind_speed = float ("-inf" )
2635- for (
2636- hour
2637- ) in (
2638- self .average_wind_speed_profile_by_hour .keys ()
2639- ): # pylint: disable=consider-iterating-dictionary,consider-using-dict-items
2640- max_wind_speed = max (
2641- max_wind_speed ,
2642- np .max (self .average_wind_speed_profile_by_hour [hour ][0 ]),
2643- )
2619+ for wind_speed_profile in self .average_wind_speed_profile_by_hour .values ():
2620+ max_wind_speed = max (max_wind_speed , np .max (wind_speed_profile [0 ]))
26442621 return max_wind_speed
26452622
26462623 # Pressure level data - Average values
@@ -2816,35 +2793,31 @@ def export_mean_profiles(self, filename="export_env_analysis"):
28162793 flipped_pressure_dict = {}
28172794 flipped_wind_x_dict = {}
28182795 flipped_wind_y_dict = {}
2819- # pylint: disable=consider-using-dict-items
2820- for (
2821- hour
2822- ) in (
2823- self .average_temperature_profile_by_hour .keys ()
2824- ): # pylint: disable=consider-iterating-dictionary
2796+
2797+ for hour , temp_profile in self .average_temperature_profile_by_hour .items ():
28252798 flipped_temperature_dict [hour ] = np .column_stack (
2826- (
2827- self .average_temperature_profile_by_hour [hour ][1 ],
2828- self .average_temperature_profile_by_hour [hour ][0 ],
2829- )
2799+ (temp_profile [1 ], temp_profile [0 ])
28302800 ).tolist ()
2801+
2802+ for hour , pressure_profile in self .average_pressure_profile_by_hour .items ():
28312803 flipped_pressure_dict [hour ] = np .column_stack (
2832- (
2833- self .average_pressure_profile_by_hour [hour ][1 ],
2834- self .average_pressure_profile_by_hour [hour ][0 ],
2835- )
2804+ (pressure_profile [1 ], pressure_profile [0 ])
28362805 ).tolist ()
2806+
2807+ for (
2808+ hour ,
2809+ wind_x_profile ,
2810+ ) in self .average_wind_velocity_x_profile_by_hour .items ():
28372811 flipped_wind_x_dict [hour ] = np .column_stack (
2838- (
2839- self .average_wind_velocity_x_profile_by_hour [hour ][1 ],
2840- self .average_wind_velocity_x_profile_by_hour [hour ][0 ],
2841- )
2812+ (wind_x_profile [1 ], wind_x_profile [0 ])
28422813 ).tolist ()
2814+
2815+ for (
2816+ hour ,
2817+ wind_y_profile ,
2818+ ) in self .average_wind_velocity_y_profile_by_hour .items ():
28432819 flipped_wind_y_dict [hour ] = np .column_stack (
2844- (
2845- self .average_wind_velocity_y_profile_by_hour [hour ][1 ],
2846- self .average_wind_velocity_y_profile_by_hour [hour ][0 ],
2847- )
2820+ (wind_y_profile [1 ], wind_y_profile [0 ])
28482821 ).tolist ()
28492822
28502823 self .export_dictionary = {
@@ -2865,23 +2838,15 @@ def export_mean_profiles(self, filename="export_env_analysis"):
28652838 "atmospheric_model_wind_velocity_y_profile" : flipped_wind_y_dict ,
28662839 }
28672840
2868- # Convert to json
2869- f = open (filename + ".json" , "w" ) # pylint: disable=consider-using-with
2870-
2871- # write json object to file
2872- f .write (
2873- json .dumps (self .export_dictionary , sort_keys = False , indent = 4 , default = str )
2874- )
2875-
2876- # close file
2877- f .close ()
2878- print (
2879- "Your Environment Analysis file was saved, check it out: "
2880- + filename
2881- + ".json"
2882- )
2841+ with open (filename + ".json" , "w" ) as f :
2842+ f .write (
2843+ json .dumps (
2844+ self .export_dictionary , sort_keys = False , indent = 4 , default = str
2845+ )
2846+ )
28832847 print (
2884- "You can use it in the future by using the customAtmosphere atmospheric model."
2848+ f"Your Environment Analysis file was saved, check it out: { filename } .json\n "
2849+ "You can use it to set a `customAtmosphere` atmospheric model"
28852850 )
28862851
28872852 @classmethod
0 commit comments