diff --git a/modules/amv/intercompare.py b/modules/amv/intercompare.py index d6b597c317aaaac66111ed89f5da101a7d1f0aae..3a23c86ebfa83346a939e3c4dcab4b0ad9bd7708 100644 --- a/modules/amv/intercompare.py +++ b/modules/amv/intercompare.py @@ -1042,6 +1042,7 @@ def best_fit(amv_spd, amv_dir, amv_prs, amv_lat, amv_lon, fcst_spd, fcst_dir, fc def best_fit_altitude(amv_spd, amv_dir, amv_alt, amv_lat, amv_lon, fcst_spd, fcst_dir, fcst_alt, + fcst_uwind=None, fcst_vwind=None, alt_top=25000.0, alt_bot=0.0, bf_half_width=500.0, constraint_half_width=400.0): verbose = False fcst_num_levels = fcst_spd.shape[0] @@ -1064,17 +1065,20 @@ def best_fit_altitude(amv_spd, amv_dir, amv_alt, amv_lat, amv_lon, fcst_spd, fcs print('AMV location lat,lon,alt ({0},{1},{2}) failed to find fcst alt around AMV'.format(amv_lat,amv_lon,amv_alt)) return bf_tup + # Compute U anv V for both AMVs and forecast + amv_uwind = -amv_spd * np.sin((np.pi/180.0)*amv_dir) + amv_vwind = -amv_spd * np.cos((np.pi/180.0)*amv_dir) + if fcst_uwind is None: + fcst_uwind = -fcst_spd * np.sin((np.pi/180.0)*fcst_dir) + fcst_vwind = -fcst_spd * np.cos((np.pi/180.0)*fcst_dir) + else: + fcst_spd = np.sqrt(fcst_uwind**2 + fcst_vwind**2) + # Diagnostic field: Find the model minimum speed and maximum speed within PressDiff of the AMV. if verbose: sat_wind_min_spd = min(fcst_spd[kk]) sat_wind_max_spd = max(fcst_spd[kk]) - # Compute U anv V for both AMVs and forecast - amv_uwind = -amv_spd * np.sin((np.pi/180.0)*amv_dir) - amv_vwind = -amv_spd * np.cos((np.pi/180.0)*amv_dir) - fcst_uwind = -fcst_spd * np.sin((np.pi/180.0)*fcst_dir) - fcst_vwind = -fcst_spd * np.cos((np.pi/180.0)*fcst_dir) - # Calculate the vector difference between the AMV and model background at all levels. vec_diff = np.sqrt((amv_uwind - fcst_uwind) ** 2 + (amv_vwind - fcst_vwind) ** 2)