diff --git a/library/meso.py b/library/meso.py index e19e69d..e73211d 100755 --- a/library/meso.py +++ b/library/meso.py @@ -158,7 +158,7 @@ def shear_group(rotation, sign, myfinaldata, az_shear, labels, resolution, dista a=len(np.where(indices[1]==m)[0]) vec_width.append(distance[0,m]*a) maxwidth=np.nanmax(vec_width) - maxlen=len(np.unique(indices[1])) + maxlen=len(np.unique(indices[1]))*resolution ratio=maxlen/maxwidth rankvel=(dvel-min_rvel)/(min_rvel) rankvort=(vort-min_vort)/(4*min_vort) @@ -216,10 +216,9 @@ def tower(rotation, areas, radar, shear, time, path): for ID in n: obj=prop.where(prop["v_ID"]==ID).dropna() if len(obj)<1: continue - towers["ID"][ID]=ID - #towers["trtlat"][ID]=obj["trtlat"].values - #towers["trtlon"][ID]=obj["trtlon"].values - towers["radar"][ID]=np.unique(obj["radar"].values) + towers = towers.astype(object) + towers.loc[ID, "ID"]=ID + towers.at[ID, "radar"]=np.unique(obj["radar"].values) r_range=[] r_elev=[] r_n=[] @@ -229,30 +228,30 @@ def tower(rotation, areas, radar, shear, time, path): r_n.append(len(o["vol"])) r_elev.append(len(np.unique(o["elevation"]))) if n == 'A': - towers["A"][ID]=1 - towers["A_range"][ID]=np.average(o["range"], weights=o["size"])*0.5 - towers["A_n"][ID]=len(o["vol"]) - towers["A_el"][ID]=len(np.unique(o["elevation"])) + towers.loc[ID, "A"]=1 + towers.loc[ID, "A_range"]=np.average(o["range"], weights=o["size"])*0.5 + towers.loc[ID, "A_n"]=len(o["vol"]) + towers.loc[ID, "A_el"]=len(np.unique(o["elevation"])) if n == 'D': - towers["D"][ID]=1 - towers["D_range"][ID]=np.average(o["range"], weights=o["size"])*0.5 - towers["D_n"][ID]=len(o["vol"]) - towers["D_el"][ID]=len(np.unique(o["elevation"])) + towers.loc[ID, "D"]=1 + towers.loc[ID, "D_range"]=np.average(o["range"], weights=o["size"])*0.5 + towers.loc[ID, "D_n"]=len(o["vol"]) + towers.loc[ID, "D_el"]=len(np.unique(o["elevation"])) if n == 'L': - towers["L"][ID]=1 - towers["L_range"][ID]=np.average(o["range"], weights=o["size"])*0.5 - towers["L_n"][ID]=len(o["vol"]) - towers["L_el"][ID]=len(np.unique(o["elevation"])) + towers.loc[ID, "L"]=1 + towers.loc[ID, "L_range"]=np.average(o["range"], weights=o["size"])*0.5 + towers.loc[ID, "L_n"]=len(o["vol"]) + towers.loc[ID, "L_el"]=len(np.unique(o["elevation"])) if n == 'P': - towers["P"][ID]=1 - towers["P_range"][ID]=np.average(o["range"], weights=o["size"])*0.5 - towers["P_n"][ID]=len(o["vol"]) - towers["P_el"][ID]=len(np.unique(o["elevation"])) + towers.loc[ID, "P"]=1 + towers.loc[ID, "P_range"]=np.average(o["range"], weights=o["size"])*0.5 + towers.loc[ID, "P_n"]=len(o["vol"]) + towers.loc[ID, "P_el"]=len(np.unique(o["elevation"])) if n == 'W': - towers["W"][ID]=1 - towers["W_range"][ID]=np.average(o["range"], weights=o["size"])*0.5 - towers["W_n"][ID]=len(o["vol"]) - towers["W_el"][ID]=len(np.unique(o["elevation"])) + towers.loc[ID, "W"]=1 + towers.loc[ID, "W_range"]=np.average(o["range"], weights=o["size"])*0.5 + towers.loc[ID, "W_n"]=len(o["vol"]) + towers.loc[ID, "W_el"]=len(np.unique(o["elevation"])) # Identify minimum range from any detecting radar # Establish range-dependent depth threshold ra=np.nanmin([towers.A_range[ID],towers.D_range[ID],towers.L_range[ID],towers.P_range[ID],towers.W_range[ID]]) @@ -264,70 +263,70 @@ def tower(rotation, areas, radar, shear, time, path): dz_min=shear["zu"]-shear["zu"]*((20-ra)/20) print("Minimum range, depth threshold", ra,dz_min) - towers["dz"][ID]=max(obj["z"])-min(obj["z"]) + towers.loc[ID, "dz"]=max(obj["z"])-min(obj["z"]) # If depth threshold not met, discard 3D object if towers["dz"][ID]0] # process each thunderstorm individually for ii in ids: - rotation_pos1, rotation_neg1 = meso.cell_loop(ii, l_mask, az_shear, mfd_conv, rotation_pos1, rotation_neg1, distance, resolution, shear, radar, coord, timelist, r, el) - rotation_pos["prop"]=pd.concat([rotation_pos["prop"],rotation_pos1["prop"]], ignore_index=True) - rotation_neg["prop"]=pd.concat([rotation_neg["prop"],rotation_neg1["prop"]], ignore_index=True) - rotation_pos["shear_objects"].append(rotation_pos1["shear_objects"]) - rotation_neg["shear_objects"].append(rotation_neg1["shear_objects"]) - rotation_pos["shear_ID"].append(rotation_pos1["shear_ID"]) - rotation_neg["shear_ID"].append(rotation_neg1["shear_ID"]) + # dict values are lists that grow within the loop + rotation_pos1, rotation_neg1 = meso.cell_loop(ii, l_mask, az_shear, mfd_conv, rotation_pos1, rotation_neg1, distance, resolution, shear, radar, coord, timelist, r, el) + + rotation_pos["prop"]=pd.concat([rotation_pos["prop"],rotation_pos1["prop"]], ignore_index=True) + rotation_neg["prop"]=pd.concat([rotation_neg["prop"],rotation_neg1["prop"]], ignore_index=True) + rotation_pos["shear_objects"].append(rotation_pos1["shear_objects"]) + rotation_neg["shear_objects"].append(rotation_neg1["shear_objects"]) + rotation_pos["shear_ID"].append(rotation_pos1["shear_ID"]) + rotation_neg["shear_ID"].append(rotation_neg1["shear_ID"]) return_dict[el]= rotation_pos, rotation_neg