@@ -402,14 +402,43 @@ def place_to_position(place: str) -> tuple:
402402
403403def plot_spatials (
404404 axs : np .ndarray ,
405- places : str = "new_orleans" ,
406- vars : Tuple [str , str ] = ("vmax" , "r0" ),
405+ place : str = "new_orleans" ,
406+ vars : Tuple [str , str ] = ("vmax_3" , "r0_3" , "rmax_3" , "rmax_1" ),
407+ labels : tuple = (
408+ "Potential intensity, $V_{p}$ [m s$^{-1}$]" ,
409+ "Corresponding potential outer size, $r_{a3}$ [km]" ,
410+ "Corresponding potential inner size, $r_{3}$ [km]" ,
411+ "Cat1 potential inner size, $r_{1}$ [km]" ,
412+ ),
407413 pi_version : int = 4 ,
408414 trial = 1 ,
409415 pressure_assumption = "isothermal" ,
410416) -> None :
411417 assert len (axs ) == len (vars )
412418
419+ name = f"august_cmip6_pi{ pi_version } _{ pressure_assumption } _trial{ trial } .nc"
420+
421+ if place in {"new_orleans" , "galverston" , "miami" }:
422+ name = "gom_" + name
423+ if place in {"shanghai" , "hong_kong" , "hanoi" }:
424+ name = "scs_" + name
425+ ds = xr .open_dataset (os .path .join (DATA_PATH , name ))
426+ print ("spatial ds" , ds )
427+
428+ ds ["lon" ].attrs = {"units" : "$^{\circ}E$" , "long_name" : "Longitude" }
429+ ds ["lat" ].attrs = {"units" : "$^{\circ}N$" , "long_name" : "Latitude" }
430+ for i , var in enumerate (vars ):
431+ if var in ds :
432+ if var in {"r0" , "rmax" , "rmax_1" , "rmax_3" , "r0_1" , "r0_3" }:
433+ (ds [var ] / 1000 ).plot (ax = axs [i ], cbar_kwargs = {"label" : "" })
434+ else :
435+ ds [var ].plot (ax = axs [i ], cbar_kwargs = {"label" : "" })
436+ axs [i ].set_title (labels [i ])
437+ point = place_to_position (place )
438+ axs [i ].scatter (* point , color = "black" , s = 75 , marker = "x" )
439+ if i != len (vars ) - 1 :
440+ axs [i ].set_xlabel ("" )
441+
413442
414443def plot_two_spatial (
415444 axs : np .ndarray ,
@@ -553,7 +582,13 @@ def get_cmip6_timeseries(
553582
554583def plot_timeserii (
555584 axs : np .ndarray ,
556- serii : tuple = ("vmax_3" , "r0_3" , "rmax_3" , "rmax_1" ),
585+ vars : tuple = ("vmax_3" , "r0_3" , "rmax_3" , "rmax_1" ),
586+ labels : tuple = (
587+ "Potential intensity, $V_{p}$ [m s$^{-1}$]" ,
588+ "PI potential outer size, $r_{a3}$ [km]" ,
589+ "PI potential inner size, $r_{3}$ [km]" ,
590+ "Cat1 potential inner size, $r_{1}$ [km]" ,
591+ ),
557592 color : str = "black" ,
558593 member : int = 4 ,
559594 model : str = "CESM2" ,
@@ -563,24 +598,34 @@ def plot_timeserii(
563598 year_min : int = 2014 ,
564599 year_max : int = 2100 ,
565600) -> None :
566- assert len (axs ) == len (serii )
601+ assert len (axs ) == len (vars )
602+ assert len (labels ) == len (vars )
567603 ds = get_cmip6_timeseries (
568604 place = place ,
569605 pressure_assumption = pressure_assumption ,
570606 member = member ,
571607 model = model ,
572608 pi_version = pi_version ,
573609 )
574- for i in range (len (serii )):
575- axs [i ].set_title (serii [i ])
610+ for i in range (len (vars )):
611+ axs [i ].set_title (vars [i ])
612+ var_np = ds [vars [i ]].values
613+ if vars [i ] in {"r0" , "rmax" , "rmax_1" , "rmax_3" , "r0_1" , "r0_3" }:
614+ var_np /= 1000
615+
576616 axs [i ].plot (
577- np .array ([t .astype ("datetime64[Y]" ).astype (int ) + 1970 for t in ds .values ]),
578- ds [serii [i ]].values ,
617+ # np.array(
618+ # [t.astype("datetime64[Y]").astype(int) + 1970 for t in ds.time.values]
619+ # ),
620+ ds ["time" ].values ,
621+ var_np ,
579622 color = color ,
580623 linewidth = 0.5 ,
624+ alpha = 0.5 ,
581625 )
626+ axs [i ].set_title (labels [i ])
582627 axs [i ].set_xlabel ("" )
583- if i == len (serii ) - 1 :
628+ if i == len (vars ) - 1 :
584629 axs [i ].set_xlabel ("Year" )
585630 axs [i ].set_xlim ([1850 , 2100 ])
586631 # vertical black line at year_min
@@ -839,6 +884,73 @@ def figure_two(place: str = "new_orleans") -> None:
839884 plt .close ()
840885
841886
887+ def multipanel (
888+ place : str = "new_orleans" ,
889+ vars : Tuple [str ] = ("vmax_3" , "r0_3" , "rmax_3" , "rmax_1" ),
890+ ):
891+ """Plot the multipanel figure for the CMIP6 timeseries.
892+
893+ Args:
894+ vars (tuple): The variables to plot (default is ("vmax_3", "r0_3", "rmax_3", "rmax_1")).
895+ """
896+ plot_defaults ()
897+ _ , axs = plt .subplots (
898+ len (vars ),
899+ 2 ,
900+ figsize = get_dim (ratio = 1.5 ),
901+ )
902+ members = [4 , 10 , 11 ]
903+ colors = ["orange" , "green" , "grey" ]
904+ plot_spatials (axs [:, 0 ], place = "new_orleans" , vars = vars )
905+ for i , member in enumerate (members ):
906+ plot_timeserii (
907+ axs [:, 1 ],
908+ vars = vars ,
909+ color = "orange" ,
910+ member = member ,
911+ model = "CESM2" ,
912+ pressure_assumption = "isothermal" ,
913+ place = "new_orleans" ,
914+ pi_version = 4 ,
915+ year_min = 2014 ,
916+ year_max = 2100 ,
917+ )
918+
919+ members = ["r1i1p1f3" , "r2i1p1f3" , "r3i1p1f3" ]
920+ for i , member in enumerate (members ):
921+ plot_timeserii (
922+ axs [:, 1 ],
923+ vars = vars ,
924+ color = "green" ,
925+ member = member ,
926+ model = "HADGEM3-GC31-MM" ,
927+ pressure_assumption = "isothermal" ,
928+ place = "new_orleans" ,
929+ pi_version = 4 ,
930+ year_min = 2014 ,
931+ year_max = 2100 ,
932+ )
933+ members = ["r1i1p1f1" , "r2i1p1f1" , "r3i1p1f1" ]
934+ for i , member in enumerate (members ):
935+ plot_timeserii (
936+ axs [:, 1 ],
937+ vars = vars ,
938+ color = "grey" ,
939+ member = member ,
940+ model = "MIROC6" ,
941+ pressure_assumption = "isothermal" ,
942+ place = "new_orleans" ,
943+ pi_version = 4 ,
944+ year_min = 2014 ,
945+ year_max = 2100 ,
946+ )
947+
948+ label_subplots (axs )
949+ plt .savefig (os .path .join (FIGURE_PATH , f"{ place } _multipanel.pdf" ))
950+ plt .clf ()
951+ plt .close ()
952+
953+
842954def temporal_relationship_data (place : str = "new_orleans" , pi_version : int = 4 ) -> None :
843955 """Get the temporal relationships data for the given place and potential intensity version.
844956
@@ -1131,8 +1243,8 @@ def _generate_header_map(columns: list[str]) -> dict[str, str]:
11311243 # python -m w22.plot
11321244 # plot_panels()
11331245 #
1134- figure_two (place = "new_orleans" )
1135- figure_two (place = "hong_kong" )
1246+ # figure_two(place="new_orleans")
1247+ # figure_two(place="hong_kong")
11361248 # temporal_relationship_data(place="new_orleans", pi_version=4)
11371249 # plot_seasonal_profiles()
11381250 # years = [2015, 2100]
@@ -1149,3 +1261,5 @@ def _generate_header_map(columns: list[str]) -> dict[str, str]:
11491261 # years=years,
11501262 # members=[4, 10],
11511263 # )
1264+ multipanel (place = "new_orleans" )
1265+ multipanel (place = "hong_kong" )
0 commit comments