Skip to content

Commit

Permalink
Merge pull request #910 from jvgeiger/fix/sonarqube-lisf-557ww-7.4
Browse files Browse the repository at this point in the history
Address SonarQube findings for upcoming LISF 557WW 7.4.5 release
  • Loading branch information
emkemp authored Oct 14, 2021
2 parents 5cc6765 + ec6d6ed commit b354341
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ def Sel_var (SEL_CIM_DATA, VAR_NAME, MODEL):
else:
VAR_SEL_CLIM_DATA = SEL_CIM_DATA.SoilMoist_tavg.sum(dim='SoilMoist_profiles') ## Summing soil moisture from all layers
if VAR_NAME == 'Surface-SM':
if (MODEL=='CLSM'):
VAR_SEL_CLIM_DATA = SEL_CIM_DATA.SoilMoist_tavg.isel(SoilMoist_profiles=0) # for clsm the total soil moisture is in the third layer
else:
VAR_SEL_CLIM_DATA = SEL_CIM_DATA.SoilMoist_tavg.isel(SoilMoist_profiles=0) ## Summing soil moisture from all layers
VAR_SEL_CLIM_DATA = SEL_CIM_DATA.SoilMoist_tavg.isel(SoilMoist_profiles=0)

elif VAR_NAME == 'Total-Runoff':
VAR_SEL_CLIM_DATA = SEL_CIM_DATA.Qs_tavg+SEL_CIM_DATA.Qsb_tavg ## Adding total surface runoff with sub-surface runoff
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def CALC_BCSD(OBS_CLIM_ALL, FCST_CLIM_ALL, LEAD_FINAL, TARGET_FCST_VAL_ARR, TARG
#BIAS_CORRECTED_VALUE = lookup(TARGET_FCST_QUANT, OBS_QUANT_TS.values, OBS_CLIM_TS.values, len(OBS_CLIM_TS.values), BC_VAR, 'DATA', obs_mean, obs_sd, obs_skew, TINY);

if (BC_VAR=='PRCP') and (BIAS_CORRECTED_VALUE<0): ## This is just a hack to check we are not getting negative value of precipitation
print (TARGET_FCST_VAL, TARGET_FCST_QUANT, fcst_yr, LEAD_NUM, ens_num, lat_num, lon_num)
print (TARGET_FCST_VAL, TARGET_FCST_QUANT, fcst_yr, LEAD_NUM, ens_num)

## Now storing the bias corrected anomaly
CORRECT_FCST_COARSE[fcst_yr, LEAD_NUM, ens_num] = BIAS_CORRECTED_VALUE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def get_F_from_data_EVI(mean, sd, x, TINY):

if(F>=1.0) or (F<=0.0):
print ("Error in get_F_from_data_EVI")
print ("Bad quantile: data={:0.2f} mean={0.2f} sd={0.2f} quant={0.2f}".format(x,mean,sd,F));
print ("Bad quantile: data={:0.2f} mean={:0.2f} sd={:0.2f} quant={:0.2f}".format(x,mean,sd,F));
sys.exit(1);
else:
return F;
Expand All @@ -226,7 +226,7 @@ def get_data_from_F_EVI(mean, sd, F, TINY):
#Gumbel (EV Type I distribution) for maxima
if(F>=1.0) or (F<=0.0):
print ("Error in get_data_from_F_EVI")
print ("Bad quantile: mean={0.2f} sd={0.2f} quant={0.2f}".format(mean,sd,F))
print ("Bad quantile: mean={:0.2f} sd={:0.2f} quant={:0.2f}".format(mean,sd,F))
sys.exit(0);
b = 3.14159/(sd*sqrt(6))
a = mean-0.5772/b
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def plotmap(var, lats, lons, lat_min, lat_max, lat_int, lon_min, lon_max, lon_in
if plottype == 'mesh':
cs=m.pcolormesh(xi, yi, var, vmax=cbmax, vmin=cbmin, cmap=cmap)
elif plottype == 'contour':
cmap = cmap
cmap.set_under(col_under)
cmap.set_over(col_higher)
norm = mpl.pyplot.cm.colors.Normalize(vmax=cbmax, vmin=cbmin, clip=False)
Expand Down
8 changes: 1 addition & 7 deletions lvt/utils/usaf/s2smetric/lib_bcsd_metrics/All_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ def Sel_var (SEL_CIM_DATA, VAR_NAME, MODEL):
VAR_SEL_CLIM_DATA = SEL_CIM_DATA.SoilMoist_tavg.isel(soil_layer=0)*0.05+SEL_CIM_DATA.SoilMoist_tavg.isel(soil_layer=1)*0.15+SEL_CIM_DATA.SoilMoist_tavg.isel(soil_layer=2)*0.3+SEL_CIM_DATA.SoilMoist_tavg.isel(soil_layer=3)*0.5

if VAR_NAME == 'Surface-SM':
if (MODEL=='CLSM'):
VAR_SEL_CLIM_DATA = SEL_CIM_DATA.SoilMoist_tavg.isel(soil_layer=0) # for clsm the total soil moisture is in the third layer
else:
VAR_SEL_CLIM_DATA = SEL_CIM_DATA.SoilMoist_tavg.isel(soil_layer=0) ## Summing soil moisture from all layers
VAR_SEL_CLIM_DATA = SEL_CIM_DATA.SoilMoist_tavg.isel(soil_layer=0)

elif VAR_NAME == 'Total-Runoff':
VAR_SEL_CLIM_DATA = SEL_CIM_DATA.Qs_tavg+SEL_CIM_DATA.Qsb_tavg ## Adding total surface runoff with sub-surface runoff
Expand All @@ -43,15 +40,12 @@ def GET_BOUNDARY(REGION_NAME):
BOUNDARY_EA = (22, 55, -12, 23); BOUNDARY_WA = (-19, 26, -5, 25)
##BOUNDARY_SA = (8, 52, -37, 0); BOUNDARY_FAME = (-20, 60, -40, 40)
BOUNDARY_SA = (8, 52, -37, 6); BOUNDARY_FAME = (-20, 55, -40, 40)
#BOUNDARY_SA1 = (24, 33, -31, -24)
if (REGION_NAME == 'EA'):
Boundary = BOUNDARY_EA
elif (REGION_NAME == 'WA'):
Boundary = BOUNDARY_WA
elif (REGION_NAME == 'SA'):
Boundary = BOUNDARY_SA
elif (REGION_NAME == 'SA1'):
Boundary = BOUNDARY_SA1
else:
Boundary = BOUNDARY_FAME
return Boundary
1 change: 0 additions & 1 deletion lvt/utils/usaf/s2smetric/lib_bcsd_metrics/Shrad_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def plotmap(var, lats, lons, lat_min, lat_max, lat_int, lon_min, lon_max, lon_in
if plottype == 'mesh':
cs=m.pcolormesh(xi, yi, var, vmax=cbmax, vmin=cbmin, cmap=cmap)
elif plottype == 'contour':
cmap = cmap
cmap.set_under(col_under)
cmap.set_over(col_higher)
norm = mpl.pyplot.cm.colors.Normalize(vmax=cbmax, vmin=cbmin, clip=False)
Expand Down

0 comments on commit b354341

Please sign in to comment.