diff --git a/modules/contrail/util.py b/modules/contrail/util.py index e1b09b2b66e1c11441dd25df08cf67f3705d65cf..7db8ddec291baf859c6c76d3486b9fc2a5f0d2cc 100644 --- a/modules/contrail/util.py +++ b/modules/contrail/util.py @@ -70,20 +70,6 @@ def extract(mask_image, image_ts, clavrx_path): for bin_num in np.unique(binned_indexes): bins_dict[bin_num] = np.where(binned_indexes == bin_num)[0] - # # This does point by point computation of model parameters for each contrail pixel - # voxel_dict = {key: [] for key in bins_dict.keys()} - # for key in bins_dict.keys(): - # print('working on pressure level: ', bins[key]) - # for c_idx in bins_dict[key]: - # lon = contrail_lons[c_idx] - # lat = contrail_lats[c_idx] - # press = contrail_press[c_idx] - # - # wind_3d = get_voxel_s(xr_dataset, ['u-wind','v-wind'], lon, lat, press) - # if wind_3d is not None: - # voxel_dict[key].append(wind_3d) - # ------------------------------------------------------------------------------------ - # This section will compute model parameters in bulk for the region then pull for each contrail pixel lon_range = [np.min(contrail_lons), np.max(contrail_lons)] lat_range = [np.min(contrail_lats), np.max(contrail_lats)] @@ -124,22 +110,28 @@ def extract(mask_image, image_ts, clavrx_path): static_value = static_3d.interp(Pressure=press, Longitude=lon, Latitude=lat, method='nearest').item(0) horz_wind_spd_value = horz_wind_spd_3d.interp(Pressure=press, Longitude=lon, Latitude=lat, method='nearest').item(0) vert_shear_value = vert_shear_3d.interp(Pressure=press, Longitude=lon, Latitude=lat, method='nearest').item(0) + temp_value = temp_3d.interp(Pressure=press, Longitude=lon, Latitude=lat, method='nearest').item(0) + rh_value = rh_3d.interp(Pressure=press, Longitude=lon, Latitude=lat, method='nearest').item(0) # tmp = horz_shear_3d.sel(Pressure=press, method='nearest') # tmp = tmp.sel(Longitude=lon, Latitude=lat, method='nearest') - voxel_dict[key].append((press_level, press, lat, lon, horz_shear_value, static_value, horz_wind_spd_value, vert_shear_value)) - all_list.append((press_level, press, lat, lon, horz_shear_value, static_value, horz_wind_spd_value, vert_shear_value)) + voxel_dict[key].append((press_level, press, lat, lon, temp_value, rh_value, horz_shear_value, static_value, horz_wind_spd_value, vert_shear_value)) + all_list.append((press_level, press, lat, lon, temp_value, rh_value, horz_shear_value, static_value, horz_wind_spd_value, vert_shear_value)) # Create pandas DataFrame for each list of tuples in voxel_dict voxel_dict_df = {} for k, v in voxel_dict.items(): print(k, len(v)) - df = pd.DataFrame(v, columns=["pressure_level", "pressure", "lat", "lon", "horz_shear_deform", "static_stability", "horz_wind_speed", "vert_wind_shear"]) + df = pd.DataFrame(v, + columns=["pressure_level", "pressure", "lat", "lon", "temperature", "relative_humidity", + "horz_shear_deform", "static_stability", "horz_wind_speed", "vert_wind_shear"]) voxel_dict_df[k] = df # Create a DataFrame for all tuples - all_df = pd.DataFrame(all_list, columns=["pressure_level", "pressure", "lat", "lon", "horz_shear_deform", "static_stability", "horz_wind_speed", "vert_wind_shear"]) + all_df = pd.DataFrame(all_list, + columns=["pressure_level", "pressure", "lat", "lon", "temperature", "relative_humidity", + "horz_shear_deform", "static_stability", "horz_wind_speed", "vert_wind_shear"]) xr_dataset.close() @@ -148,7 +140,6 @@ def extract(mask_image, image_ts, clavrx_path): def analyze(dataFrame, column, value): result_df = dataFrame[dataFrame[column] == value] # get rows where column has a certain value - print(result_df.head()) mean = result_df.mean() # calculate mean for other columns stddev = result_df.std() # calculate standard deviation for other columns