Skip to content

Commit

Permalink
Clean up commented out print statements throughout
Browse files Browse the repository at this point in the history
  • Loading branch information
rthedin committed Sep 29, 2022
1 parent 6fb5d72 commit 43a728f
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 43 deletions.
17 changes: 0 additions & 17 deletions ssrs/hrrr/hrrr.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ def get_xarray_for_regex(self, regex, remove_grib=False):
Datasets if the requested variables have different
coordinates.
"""
#print(f'regex is {regex}')
if regex not in self.datasets:
# Retrieve GRIB2 data with Herbie
# Note: There is an issue with how Herbie handles regular
Expand All @@ -235,16 +234,11 @@ def get_xarray_for_regex(self, regex, remove_grib=False):
remove_grib=remove_grib
)

#print(f'ds in hrrr is {ds}')
#print(f'len of ds is {len(ds)}')
#print(f'type of ds is {type(ds)}')
# Sometimes we have a list of xarray Dataset, depending on the
# regex requested. To make sure the coords call below is available,
# we get the first Dataset from the list
if isinstance(ds, list):
#print(f'ds is a list')
for i, ds_curr in enumerate(ds):
#print(f'\n\nthis is a single ds, number {i}: {ds_curr}\n\n')
# Convert longitude from degrees east with range (0,360) to
# degrees east/west for +/- values with range (-180,180)
lon = ds[i].coords['longitude'].values
Expand Down Expand Up @@ -499,7 +493,6 @@ def wind_velocity_direction_at_altitude(
vs = uv_grd[v_data_var].where(mask, drop=True).values.flatten()
us = us[~np.isnan(us)]
vs = vs[~np.isnan(vs)]
#print(f'inside hrrr. us is {us}')
#print(f'inside hrrr. shape of us is {np.shape(us)}')

# Use linear B-spline interpolation to find U and V values
Expand Down Expand Up @@ -678,7 +671,6 @@ def mask_at_coordinates(
The mask to be used with the coordinates of the xarray
dataset.
"""
#print(f'inside mask_at_coordinate, southwest_lonlat is {southwest_lonlat}')

try:
southwest_lon, southwest_lat = southwest_lonlat
Expand Down Expand Up @@ -897,7 +889,6 @@ def get_albedo(self, southwest_lonlat=None, extent=None, res=50):
)

# Let's make sure the Su and Sd xarrays only really one data variable
#print(f'variables in Su are {list(Su.keys())}')
if len(list(Su.keys())) != 1:
raise ValueError(f"Computation of Su inside get_albedo returned more",\
f"than one data variable. This shouldn't occur")
Expand All @@ -910,8 +901,6 @@ def get_albedo(self, southwest_lonlat=None, extent=None, res=50):
Su = Su[list(Su.keys())[0]]
Sd = Sd[list(Sd.keys())[0]]

#print(f'Su is {Su}')
#print(f'mean of Su is {np.mean(Su)}')
if np.mean(Su) == 0:
alpha_surface_albedo = np.ones_like(Su) # night
# TODO: this is a placeholder. We should just compute the
Expand Down Expand Up @@ -962,12 +951,8 @@ def interp_onto_regular_grid(
xform_lat_sq = xform_lat_sq - yref

# create grid. bounds is now [xmin, xmax, ymin, ymax]
#print(f'bounds is (should be xmin,xmax, ymin,ymax) {bounds}')
x = np.arange(bounds[0], bounds[2], res)
y = np.arange(bounds[1], bounds[3], res)
#print(f'inside interp_onto_regular_grid. x is {x}')
#print(f'inside interp_onto_regular_grid. y is {y}')
#print(f'inside interp_onto_regular_grid. res is {res}')

# Sometimes when the division of the domain extent and resolution is not
# a round number, we end up with arrays that are 1 position too large.
Expand Down Expand Up @@ -1091,8 +1076,6 @@ def get_var_on_grid(self,
data_interp[varname] = (('x','y'), fi)

# Set dimension coordinate
#print(f'shape of xx is {np.shape(xx)}')
#print(f'shape of yy is {np.shape(yy)}')
data_interp = data_interp.assign_coords(x=xx[:,0], y=yy[0,:])

return data_interp, xx, yy
Expand Down
10 changes: 0 additions & 10 deletions ssrs/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ def calcOrographicUpdraft_original(
w0_abovemin = np.maximum(min_updraft_val, w0)
w0_abovemin_coarse = highRes2lowRes(w0_abovemin, res_terrain, res)

#np.savetxt('wo_orig.csv',w0_abovemin_coarse,fmt='%.2f', delimiter=',')

return w0_abovemin_coarse


Expand Down Expand Up @@ -123,16 +121,9 @@ def highRes2lowRes(field, res_h, res_l, sigma_in_m=30):
"""

ratio = res_h/res_l
#print(f'ratio to get a high res array to low res is {ratio}')
if ratio == 1:
# same resolution, nothing to do here
return field
#elif ratio == 1/3:
#print(f'inside the if for ratio==1/3')
# This ratio results in the coarsened array having one position less
# It is due to fact that 4000/3 is, rounded, 1333. But in case such
# as this one, we want 1334. So we manually round the ratio.
#ratio = 0.3334

sigma = sigma_in_m/res_h
if sigma<=1:
Expand Down Expand Up @@ -619,7 +610,6 @@ def compute_thermals_3d(
albedo = albedo.values
zi = zi[list(zi.keys())[0]].values

#print(f'zi is {zi}')
if np.mean(zi) == np.nan:
raise ValueError(f'The value obtained for the boundary layer height contains NaNs.',\
f'HRRR data is imcomplete at the site and time of interest.')
Expand Down
5 changes: 0 additions & 5 deletions ssrs/movmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,6 @@ def generate_heuristic_eagle_track(
random_walk_step_range: tuple = (None,None) # when a random walk does occur, the number of random steps will occur in this range
):

#print(f'inside generate_heuristic_eagle_track. Shape of orographic w0 is {np.shape(wo)}; shape of thermal wt is {np.shape(wt)}')

assert random_walk_freq >= 0
assert (len(random_walk_step_range) == 2)

Expand Down Expand Up @@ -344,8 +342,6 @@ def generate_heuristic_eagle_track(
yg = np.arange(num_rows) * res
maxx = xg[-1]
maxy = yg[-1]
#print(f'maxxg=',xg[-1],'maxyg=',yg[-1])
#print(f'shape of wo is',np.shape(wo))

# setup updraft and elevation interpolation and smoothed wo for lookahead
wo_interp = RectBivariateSpline(xg, yg, wo.T)
Expand Down Expand Up @@ -442,7 +438,6 @@ def generate_heuristic_eagle_track(
last_pos = trajectory[-1]
for cur_pos in new_pos:
if not ((0 < cur_pos[0] < xg[-1]) and (0 < cur_pos[1] < yg[-1])):
#print('ending after',imove,'moves')
break
delta = tuple(map(lambda i,j:i-j, cur_pos, last_pos))
#delta = cur_pos - last_pos (this gives an error, unsupported operand for tuple)
Expand Down
11 changes: 0 additions & 11 deletions ssrs/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,6 @@ def compute_orographic_updrafts_using_hrrr(self) -> None:
aspect = self.get_terrain_aspect()
elev = self.get_terrain_elevation()

#print(f'the entire hrrr object is {self.hrrr}')
start_time = time.time()
for t, (dtime, case_id) in enumerate( zip(self.dtimes, self.case_ids) ):
#wtk_df = self.wtk.get_dataframe_for_this_time(dtime)
Expand Down Expand Up @@ -609,11 +608,6 @@ def compute_thermal_updrafts(self, case_id: str):
# We have a list of datetime (possibly of size 1), let's iterate through them
for time in self.dtimes:
print(f'Calculating thermals for {time}')
#print(f'passing to compute_thermals_3d, southwest_lonlat is {self.southwest_lonlat}')
#print(f'passing to compute_thermals_3d, extent is {self.extent}')
# maybe the second argumetn should be self.lonlat_bounds[0:2] to get the xmin, ymin (southwest)
# Somehow, SOMEHOW, the extent now is xmin,xmax,ymin,ymax, when it used to be xmin,ymin,xmax,ymax.
# The thermal3d function used to get it in the old format. Changing it
extent_for_thermals_3d = [0, 0, self.region_width_km[0]*1000, self.region_width_km[1]*1000] # xmin, ymin, xmax, ymax
thermals = compute_thermals_3d(aspect, self.southwest_lonlat, extent_for_thermals_3d, self.resolution,
time, self.h, wfipInformed=False)
Expand All @@ -630,7 +624,6 @@ def load_updrafts(self, case_id: str, apply_threshold=True):
""" Computes updrafts for the particular case """
fname = self._get_orographicupdraft_fname(case_id, self.mode_data_dir)
orographicupdraft = np.load(f'{fname}.npy')
#print(f'inside load_updrafts, loaded {fname}.npy, with shape {np.shape(orographicupdraft)}.')
print(f'Found orographic updraft {os.path.basename(fname)}. Loading it...')

updrafts= orographicupdraft
Expand Down Expand Up @@ -1303,8 +1296,6 @@ def plot_updrafts(self, apply_threshold=True, plot_turbs=True,
# Single updraft field
updrafts = [updrafts]

#print(f'updrafts shape is {np.shape(updrafts)}')

for real_id, updraft in enumerate(updrafts):
#print(f'inside plot_updraft. updraft shape is {np.shape(updraft)}')
fig, axs = plt.subplots(figsize=self.fig_size)
Expand Down Expand Up @@ -2034,8 +2025,6 @@ def plot_atmospheric_conditions_HRRR(self, show=False) -> None:
extent = [0, 0, self.region_width_km[0]*1000, self.region_width_km[1]*1000] # xmin, ymin, xmax, ymax
res = self.resolution

#print(f'Extent is {extent}')

# Compute wstar
wstar, xx, yy = hrrr.get_convective_velocity(SWlonlat, extent, res)

Expand Down

0 comments on commit 43a728f

Please sign in to comment.