euler314 commited on
Commit
111d9eb
·
verified ·
1 Parent(s): 84e165d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -7
app.py CHANGED
@@ -596,7 +596,10 @@ def update_route_clusters(start_year, start_month, end_year, end_month, enso_val
596
  lon_i = interp1d(t, lons, kind='linear', fill_value='extrapolate')(t_new)
597
  lat_i = interp1d(t, lats, kind='linear', fill_value='extrapolate')(t_new)
598
  vmax_i = interp1d(t, vmax, kind='linear', fill_value='extrapolate')(t_new)
599
- mslp_i = interp1d(t, mslp, kind='linear', fill_value='extrapolate')(t_new)
 
 
 
600
  except Exception as e:
601
  continue
602
  route_vector = np.column_stack((lon_i, lat_i)).flatten()
@@ -655,12 +658,16 @@ def update_route_clusters(start_year, start_month, end_year, end_month, enso_val
655
  cluster_lons.append(lon_i)
656
  cluster_lats.append(lat_i)
657
  cluster_v.append(storms_vmax_list[idx])
658
- cluster_p.append(storms_mslp_list[idx])
 
659
  if cluster_lons and cluster_lats:
660
  mean_lon = np.mean(cluster_lons, axis=0)
661
  mean_lat = np.mean(cluster_lats, axis=0)
662
  mean_v = np.mean(cluster_v, axis=0)
663
- mean_p = np.mean(cluster_p, axis=0)
 
 
 
664
  cluster_mean_routes.append((mean_lon, mean_lat))
665
  cluster_mean_vmax.append(mean_v)
666
  cluster_mean_mslp.append(mean_p)
@@ -767,10 +774,11 @@ def update_route_clusters(start_year, start_month, end_year, end_month, enso_val
767
  go.Scatter(y=cluster_mean_vmax[i], mode='lines', line=dict(width=2, color=cluster_colors[i % len(cluster_colors)]), name=name),
768
  row=1, col=1
769
  )
770
- fig_stats.add_trace(
771
- go.Scatter(y=cluster_mean_mslp[i], mode='lines', line=dict(width=2, color=cluster_colors[i % len(cluster_colors)]), name=name),
772
- row=2, col=1
773
- )
 
774
  fig_stats.update_layout(
775
  title="Cluster Average Wind & Pressure Profiles",
776
  xaxis_title="Route Normalized Index",
 
596
  lon_i = interp1d(t, lons, kind='linear', fill_value='extrapolate')(t_new)
597
  lat_i = interp1d(t, lats, kind='linear', fill_value='extrapolate')(t_new)
598
  vmax_i = interp1d(t, vmax, kind='linear', fill_value='extrapolate')(t_new)
599
+ if not np.all(np.isnan(mslp)):
600
+ mslp_i = interp1d(t, mslp, kind='linear', fill_value='extrapolate')(t_new)
601
+ else:
602
+ mslp_i = np.full(max_length, np.nan)
603
  except Exception as e:
604
  continue
605
  route_vector = np.column_stack((lon_i, lat_i)).flatten()
 
658
  cluster_lons.append(lon_i)
659
  cluster_lats.append(lat_i)
660
  cluster_v.append(storms_vmax_list[idx])
661
+ if not np.all(np.isnan(storms_mslp_list[idx])):
662
+ cluster_p.append(storms_mslp_list[idx])
663
  if cluster_lons and cluster_lats:
664
  mean_lon = np.mean(cluster_lons, axis=0)
665
  mean_lat = np.mean(cluster_lats, axis=0)
666
  mean_v = np.mean(cluster_v, axis=0)
667
+ if cluster_p:
668
+ mean_p = np.nanmean(cluster_p, axis=0)
669
+ else:
670
+ mean_p = np.full(max_length, np.nan)
671
  cluster_mean_routes.append((mean_lon, mean_lat))
672
  cluster_mean_vmax.append(mean_v)
673
  cluster_mean_mslp.append(mean_p)
 
774
  go.Scatter(y=cluster_mean_vmax[i], mode='lines', line=dict(width=2, color=cluster_colors[i % len(cluster_colors)]), name=name),
775
  row=1, col=1
776
  )
777
+ if not np.all(np.isnan(cluster_mean_mslp[i])):
778
+ fig_stats.add_trace(
779
+ go.Scatter(y=cluster_mean_mslp[i], mode='lines', line=dict(width=2, color=cluster_colors[i % len(cluster_colors)]), name=name),
780
+ row=2, col=1
781
+ )
782
  fig_stats.update_layout(
783
  title="Cluster Average Wind & Pressure Profiles",
784
  xaxis_title="Route Normalized Index",