o ng<@sRdZddlZddlmZddlZddlZddlZddlZ ddl Z GdddZ dS)zw Name: subseasonal_plots_specs.py Contact(s): Shannon Shields Abstract: This script defines plotting related settings. Nc@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!S)" PlotSpecscCsd||_||_d|_d|_d|_d|_d|_d|_d|_d|_ d|_ d|_ d|_ d|_ d|_d|_d|_d|_d|_d |_d |_d |_d |_d |_d|_d|_d|_d|_d|_d|_d|_d|_|jdvrd|_d|_d|_d |_d|_d|_ d|_ d|_ d|_d|_d|_|jdvrd|_d9Sd9S|jdkrd|_d|_d|_d |_d|_d|_ d|_ d|_ d9S|jdvrd|_d|_d|_d |_d!|_d|_d|_d"|_d#|_|jd$krd|_d9Sd9S|jd%vrd|_d"|_d&|_d|_d |_d'|_d(|_d#|_|jd)krd|_d|_|jd*krd|_d9Sd9S|jd+kr=d|_d |_d|_d |_d|_d|_d,|_d|_d|_d-|_d#|_d9S|jd.kr]d|_d"|_d&|_d|_d/|_d|_d|_d#|_d9S|jd0krzd1|_d|_d2|_d/|_d3|_ d3|_ d|_ d9S|jd4krd|_d|_d5|_d|_d |_d|_d6|_d"|_d|_d#|_d9S|j!d7|jd8t"#dd9S):z! Initialize PlotSpecs class Args: logger - logger object plot_type - type of graphic being produced (string) Returns: boldcenterF ffffff?皙?g?g333333???r?T)r r )0@r) time_seriestime_series_multifhrlong_term_time_serieslong_term_time_series_multifhr)r @gףp= ?g(\µ?)?皙?)rrrg333333? histogram) lead_averagevalid_hour_averagethreshold_averagelong_term_time_series_diff?rgq= ףp?gQ?r) lead_by_datelong_term_annual_meanlong_term_lead_by_dateleftgK7?g333333?r!r" stat_by_level)g{Gz?gףp= ?z upper left lead_by_levelg?Zprecip_spatial_map)rg@g333333? performance_diagramgffffff?z upper centerz FATAL ERROR, z NOT RECOGNIZEDN)$ plot_typelogger font_weightaxis_title_weightaxis_title_sizeaxis_title_padaxis_title_loc axis_offsetaxis_label_weightaxis_label_sizeaxis_label_padxtick_label_sizextick_major_padytick_label_sizeytick_major_padfig_title_weightfig_title_sizefig_subplot_rightfig_subplot_leftfig_subplot_topfig_subplot_bottomlegend_handle_text_padlegend_handle_lengthlegend_border_axis_padlegend_col_spacelegend_frame_onZ legend_bboxZlegend_font_sizeZ legend_locZ legend_ncolZ title_locZfig_sizeZaxis_tick_sizeerrorsysexit)selfr)r(rFP/lfs/h1/ops/prod/packages/evs.v1.0.19/ush/subseasonal/subseasonal_plots_specs.py__init__s                     zPlotSpecs.__init__cCsH|jtjd<|jtjd<|jtjd<|jtjd<|jtjd<|jtjd<|jtjd<|j tjd<|j tjd <|j tjd <|j tjd <|j tjd <|jtjd <|jtjd<|jtjd<|jtjd<|jtjd<|jtjd<|jtjd<|jtjd<|jtjd<|jtjd<|jtjd<|jtjd<ttjdddkrdtjd<dSdS)zU! Set up the matplotlib rcParams Args: Returns: z font.weightzaxes.titleweightzaxes.titlesizez axes.titlepadzaxes.titlelocationzaxes.labelweightzaxes.labelsizez axes.labelpadzaxes.formatter.useoffsetzxtick.labelsizezxtick.major.padzytick.labelsizezytick.major.padzfigure.subplot.leftzfigure.subplot.rightzfigure.subplot.topzfigure.subplot.bottomzfigure.titleweightzfigure.titlesizezlegend.handletextpadzlegend.handlelengthzlegend.borderaxespadzlegend.columnspacingzlegend.frameonrgffffff @z0000-12-31T00:00:00z date.epochN)r*pltZrcParamsr+r,r-r.r0r1r2r/r3r4r5r6r:r9r;r<r7r8r=r>r?r@rAfloat matplotlib __version__)rErFrFrG set_up_plots6                        zPlotSpecs.set_up_plotcCsiddddddddd d d d d ddddddddddddddddddd d!d"d#d$i}|t|vrG||}|S|j|d%|d&|}|S)'ad! Get the full statistic name that will be displayed on the plot Args: stat - abbreviated statistic name (string) Returns: stat_plot_name - full statistic name that will be displayed on the plot (string) ACCzAnomaly Correlation CoefficientBIASzBias (Mean Error)CSIzCritical Success IndexETSzEquitable Threat ScoreFBARz Forecast Mean FBAR_OBARzForecast and Observation MeanFBIASzFrequency BiasFSSzFraction Skill ScoreFY_OYzForecast:Yes,Obs:YesGSSzGilbert Skill ScoreHSSzHeidke Skill ScoreMEzMean Error (Bias)OBARzObservation MeanPODzProbability of DetectionPERF_DIAzPerformance DiagramRMSEzRoot Mean Square ErrorS1zS1 ScoreSRATIOzSuccess Ratio (1-FAR)z not recognized, using  on plotlistkeysr)debug)rEstatZstat_plot_name_dictZstat_plot_namerFrFrGget_stat_plot_namesV      zPlotSpecs.get_stat_plot_namec Cs|d|}iddddddddd d d d d ddddddddddddddddddd d!d"id#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDidEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfidgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~ddddddddddiddddddddddddddddddddddddddddddddddidddddddddddddddddddddddd“ddēddƓddȓddʓdd̓iddΓddГddғddԓdd֓ddؓddړddܓddޓddddddddddddddddiddddddddddddddddddddddddddddd d d d d didddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0id1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRidSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtidudvdwdxdydzd{d|d}d~dddddddddddddddddddddddddddddddd}|t|vr:||}|S|j|dd|d|}|S(a! Get the full variable information that will be displayed on the plot Args: var_name - abbreviated variable name (string) var_level - abbreviated variable level (string) Returns: var_plot_name - full variable information that will be displayed on the plot (string) /zAPCP/A24z!24 hour Accumulated Precipitationz APCP_A24/A24z CAPE/P90-0zMixed-Layer CAPEzCAPE/Z0zSurface Based CAPEzCFRZR/L0z"Precipitation Type - Freezing RainzCICEP/L0z Precipitation Type - Ice PelletszCRAIN/L0zPrecipitation Type - RainzCSNOW/L0zPrecipitation Type - SnowzCWAT/L0z Cloud WaterzDPT/Z2z2 meter DewpointzGUST/Z0zSurface Wind Gustz HGT/CEILINGZCeilingzHGT/allz Geopotential Height - All LevelszHGT/tropz!Geopotential Height - Tropospherez HGT/ltropz'Geopotential Height - Lower Tropospherez HGT/utropz'Geopotential Height - Upper Tropospherez HGT/stratz"Geopotential Height - StratospherezHGT/P1z1 hPa Geopotential HeightzHGT/P5z5 hPa Geopotential HeightzHGT/P10z10 hPa Geopotential HeightzHGT/P20z20 hPa Geopotential HeightzHGT/P50z50 hPa Geopotential HeightzHGT/P100z100 hPa Geopotential HeightzHGT/P150z150 hPa Geopotential HeightzHGT/P200z200 hPa Geopotential HeightzHGT/P250z250 hPa Geopotential HeightzHGT/P300z300 hPa Geopotential HeightzHGT/P400z400 hPa Geopotential HeightzHGT/P500z500 hPa Geopotential HeightzHGT/P700z700 hPa Geopotential HeightzHGT/P850z850 hPa Geopotential HeightzHGT/P925z925 hPa Geopotential Heightz HGT/P1000z1000 hPa Geopotential HeightzHGT/TROPOPAUSEzTropopause Geopotential HeightzHGT_ANOM_WEEKLYAVG/P500z.500 hPa Weekly Avg Geopotential Height AnomalyzHGT_ANOM_DAYS6_10AVG/P500z1500 hPa Days 6-10 Avg Geopotential Height AnomalyzHGT_ANOM_WEEKS3_4AVG/P500z1500 hPa Weeks 3-4 Avg Geopotential Height AnomalyzHGT_DECOMP_WV1_0-3/P500z&500 hPa Geopotential Height: Waves 0-3zHGT_DECOMP_WV1_0-20/P500z'500 hPa Geopotential Height: Waves 0-20zHGT_DECOMP_WV1_4-9/P500z&500 hPa Geopotential Height: Waves 4-9zHGT_DECOMP_WV1_10-20/P500z(500 hPa Geopotential Height: Waves 10-20zHPBL/L0zPlanetary Boundary Layer HeightzICEC_WEEKLYAVG/Z0zWeekly Avg Ice ConcentrationzICEC_MONTHLYAVG/Z0zMonthly Avg Ice ConcentrationzO3MR/allzOzone Mixing Ratio - All Levelsz O3MR/tropz Ozone Mixing Ratio - Tropospherez O3MR/ltropz&Ozone Mixing Ratio - Lower Tropospherez O3MR/utropz&Ozone Mixing Ratio - Upper Tropospherez O3MR/stratz!Ozone Mixing Ratio - StratospherezO3MR/P1z1 hPa Ozone Mixing RatiozO3MR/P5z5 hPa Ozone Mixing RatiozO3MR/P10z10 hPa Ozone Mixing RatiozO3MR/P20z20 hPa Ozone Mixing RatiozO3MR/P30z30 hPa Ozone Mixing RatiozO3MR/P50z50 hPa Ozone Mixing RatiozO3MR/P70z70 hPa Ozone Mixing Ratioz O3MR/P100z100 hPa Ozone Mixing Ratioz O3MR/P925z925 hPa Ozone Mixing RatiozPRES/TROPOPAUSEzTropopause PressurezPRES/Z0zSurface PressurezPRMSL/Z0zPressure Reduced to MSLzPWAT/L0zPrecipitable WaterzRH/allzRelative Humidity - All LevelszRH/tropzRelative Humidity - TropospherezRH/ltropz%Relative Humidity - Lower TropospherezRH/utropz%Relative Humidity - Upper TropospherezRH/stratz Relative Humidity - StratospherezRH/P1z1 hPa Relative HumidityzRH/P5z5 hPa Relative HumidityzRH/P10z10 hPa Relative HumidityzRH/P20z20 hPa Relative HumidityzRH/P50z50 hPa Relative HumidityzRH/P100z100 hPa Relative HumidityzRH/P150z150 hPa Relative HumidityzRH/P200z200 hPa Relative HumidityzRH/P250z250 hPa Relative HumidityzRH/P300z300 hPa Relative HumidityzRH/P400z400 hPa Relative HumidityzRH/P500z500 hPa Relative HumidityzRH/P700z700 hPa Relative HumidityzRH/P850z850 hPa Relative HumidityzRH/P925z925 hPa Relative HumidityzRH/P1000z1000 hPa Relative HumidityzRH/Z2z2 meter Relative Humidityz SNOD_A24/Z0z-24 hour Snow Accumulation (derived from SNOD)z SOILW/Z0.1-0z,0.1-0 meter Volumetric Soil Moisture ContentzSPFH/allzSpecific Humidity - All Levelsz SPFH/tropzSpecific Humidity - Tropospherez SPFH/ltropz%Specific Humidity - Lower Tropospherez SPFH/utropz%Specific Humidity - Upper Tropospherez SPFH/stratz Specific Humidity - StratospherezSPFH/P1z1 hPa Specific HumidityzSPFH/P5z5 hPa Specific HumidityzSPFH/P10z10 hPa Specific HumidityzSPFH/P20z20 hPa Specific HumidityzSPFH/P50z50 hPa Specific Humidityz SPFH/P100z100 hPa Specific Humidityz SPFH/P150z150 hPa Specific Humidityz SPFH/P200z200 hPa Specific Humidityz SPFH/P250z250 hPa Specific Humidityz SPFH/P300z300 hPa Specific Humidityz SPFH/P400z400 hPa Specific Humidityz SPFH/P500z500 hPa Specific Humidityz SPFH/P700z700 hPa Specific Humidityz SPFH/P850z850 hPa Specific Humidityz SPFH/P925z925 hPa Specific Humidityz SPFH/P1000z1000 hPa Specific HumidityzSPFH/Z2z2 meter Specific HumidityzSST_DAILYAVG/Z0z!Daily Avg Sea Surface TemperaturezSST_WEEKLYAVG/Z0z"Weekly Avg Sea Surface TemperaturezSST_MONTHLYAVG/Z0z#Monthly Avg Sea Surface Temperaturez TCDC/TOTALzTotal Cloud CoverzTMP/allzTemperature - All LevelszTMP/tropzTemperature - Tropospherez TMP/ltropzTemperature - Lower Tropospherez TMP/utropzTemperature - Upper Tropospherez TMP/stratzTemperature - StratospherezTMP/P1z1 hPa TemperaturezTMP/P5z5 hPa TemperaturezTMP/P10z10 hPa TemperaturezTMP/P20z20 hPa TemperaturezTMP/P50z50 hPa TemperaturezTMP/P100z100 hPa TemperaturezTMP/P150z150 hPa TemperaturezTMP/P200z200 hPa TemperaturezTMP/P250z250 hPa TemperaturezTMP/P300z300 hPa TemperaturezTMP/P400z400 hPa TemperaturezTMP/P500z500 hPa TemperaturezTMP/P700z700 hPa TemperaturezTMP/P850z850 hPa TemperaturezTMP/P925z925 hPa Temperaturez TMP/P1000z1000 hPa TemperaturezTMP/TROPOPAUSEzTropopause TemperaturezTMP/Z2z2 meter TemperaturezTMP_ANOM_WEEKLYAVG/Z2z&2 meter Weekly Avg Temperature AnomalyzTMP_ANOM_DAYS6_10AVG/Z2z)2 meter Days 6-10 Avg Temperature AnomalyzTMP_ANOM_WEEKS3_4AVG/Z2z)2 meter Weeks 3-4 Avg Temperature AnomalyzTOZNE/L0z Total Ozonez TSOIL/Z0.1-0z0.1-0 meter Soil TemperaturezUGRD/allz U-Component of Wind - All Levelsz UGRD/tropz!U-Component of Wind - Tropospherez UGRD/ltropz'U-Component of Wind - Lower Tropospherez UGRD/utropz'U-Component of Wind - Upper Tropospherez UGRD/stratz"U-Component of Wind - StratospherezUGRD/P1z1 hPa U-Component of WindzUGRD/P5z5 hPa U-Component of WindzUGRD/P10z10 hPa U-Component of WindzUGRD/P20z20 hPa U-Component of WindzUGRD/P50z50 hPa U-Component of Windz UGRD/P100z100 hPa U-Component of Windz UGRD/P150z150 hPa U-Component of Windz UGRD/P200z200 hPa U-Component of Windz UGRD/P250z250 hPa U-Component of Windz UGRD/P300z300 hPa U-Component of Windz UGRD/P400z400 hPa U-Component of Windz UGRD/P500z500 hPa U-Component of Windz UGRD/P700z700 hPa U-Component of Windz UGRD/P850z850 hPa U-Component of Windz UGRD/P925z925 hPa U-Component of Windz UGRD/P1000z1000 hPa U-Component of WindzUGRD/Z10z10 meter U-Component of Windz UGRD_VGRD/allzVector Wind - All LevelszUGRD_VGRD/tropzVector Wind - TropospherezUGRD_VGRD/ltropzVector Wind - Lower TropospherezUGRD_VGRD/utropzVector Wind - Upper TropospherezUGRD_VGRD/stratzVector Wind - Stratospherez UGRD_VGRD/P1z1 hPa Vector Windz UGRD_VGRD/P5z5 hPa Vector Windz UGRD_VGRD/P10z10 hPa Vector Windz UGRD_VGRD/P20z20 hPa Vector Windz UGRD_VGRD/P50z50 hPa Vector WindzUGRD_VGRD/P100z100 hPa Vector WindzUGRD_VGRD/P150z150 hPa Vector WindzUGRD_VGRD/P200z200 hPa Vector WindzUGRD_VGRD/P250z250 hPa Vector WindzUGRD_VGRD/P300z300 hPa Vector WindzUGRD_VGRD/P400z400 hPa Vector WindzUGRD_VGRD/P500z500 hPa Vector WindzUGRD_VGRD/P700z700 hPa Vector WindzUGRD_VGRD/P850z850 hPa Vector WindzUGRD_VGRD/P925z925 hPa Vector WindzUGRD_VGRD/P1000z1000 hPa Vector Windz UGRD_VGRD/Z10z10 meter Vector WindzVIS/Z0Z VisibilityzVGRD/allz V-Component of Wind - All Levelsz VGRD/tropz!V-Component of Wind - Tropospherez VGRD/ltropz'V-Component of Wind - Lower Tropospherez VGRD/utropz'V-Component of Wind - Upper Tropospherez VGRD/stratz"V-Component of Wind - StratospherezVGRD/P1z1 hPa V-Component of WindzVGRD/P5z5 hPa V-Component of WindzVGRD/P10z10 hPa V-Component of WindzVGRD/P20z20 hPa V-Component of WindzVGRD/P50z50 hPa V-Component of Windz VGRD/P100z100 hPa V-Component of Windz VGRD/P150z150 hPa V-Component of Windz VGRD/P200z200 hPa V-Component of Windz VGRD/P250z250 hPa V-Component of Windz VGRD/P300z300 hPa V-Component of Windz VGRD/P400z400 hPa V-Component of Windz VGRD/P500z500 hPa V-Component of Windz VGRD/P700z700 hPa V-Component of Windz850 hPa V-Component of Windz925 hPa V-Component of Windz1000 hPa V-Component of Windz10 meter V-Component of Windz*Water Equivalent of Accumulated Snow Depthz.24 hour Snow Accumulation (derived from WEASD)zWind Shear (850-200 hPa))z VGRD/P850z VGRD/P925z VGRD/P1000zVGRD/Z10zWEASD/Z0z WEASD_A24/Z0zWNDSHR/P850-P200 not recognized, using rarb)rEvar_nameZ var_levelZvar_name_levelZvar_plot_name_dictZ var_plot_namerFrFrGget_var_plot_names       !"#%')+-/123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVW _zPlotSpecs.get_var_plot_namecCs$iddddddddddd d d d d d ddddddddddddddddddidd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d3d4d5d6d7d8d9d:d;dd?d@dAdB}|t|vr||}|S|j|dCdD|dE|}|S)Fa! Get the full verification masking information that will be displayed on the plot Args: vx_mask - abbreviated verification mask name (string) Returns: vx_mask_plot_name - full verification mask name that will be displayed on the plot (string) Alaska ANTARCTICzAntarctic 50S-90S AppalachiaARCTICzArctic 50N-90NATL_MDRz Atlantic Main Development RegionCONUS CONUS_CentralzCONUS - Central CONUS_Eastz CONUS - East CONUS_Southz CONUS - South CONUS_Westz CONUS - WestCPlainszCentral Plains DeepSouthz Deep SouthEPAC_MDRz$East Pacific Main Development RegionGLOBALGlobal GreatBasinz Great Basin GreatLakesz Great LakesZ Mezquital MidAtlanticz Mid-AtlanticN60N90z60N-90NNAOzNorthern Atlantic OceanNPOzNorthern Pacific OceanNHEMzNorthern Hemisphere 20N-80N NorthAtlanticzNortheast (North Atlantic)NPlainszNorthern PlainsNRockieszNorthern Rockies PacificNWzPacific Northwest PacificSWzPacific SouthwestPrairieS60S90z60S-90SSAOzSouthern Atlantic OceanSPOzSouthern Pacific OceanSHEMzSouthern Hemisphere 20S-80S Southeast SouthwestzSouthern PlainszSouthern RockieszTropics 20S-20NHawaii)SPlainsSRockiesTROPICSrrirjrarb)rEvx_maskZvx_mask_plot_name_dictZvx_mask_plot_namerFrFrGget_vx_mask_plot_names       !"#( zPlotSpecs.get_vx_mask_plot_namec Cs^|d}tj|d} tj|d} || dd| dd}g} |dkrw|D]7} |D]2} tt| ddt| }t| dd| vrbt| dd|vrb| t| ddq0q,| |d |d d | }n\|d kr|D]C} |D]>} t t| ddt| }t| dd| vrt| dd|vr| t| dd| tt ddqq}| |d |d d | }|d vr-g}|D]!} t| d}t| ddkr| tt|q| t|qt|dkr|d|ddd|dd}|S|dd |ddd |d}|S)a0! Get the full date information that will be displayed on the plot Args: date_type - type of dates (string, VALID or INIT) start_date - starting date (string, YYYYmmdd) end_date - ending date (string, YYYYmmdd) date_type_hr_list - list of hours for date_type other_hr_list - list of hours for opposite of date_type (strings) forecast_hour_list - list of forecast hour(s), if not applicable is NA plot_type - type of plot (string) Returns: date_plot_name - full date information that will be displayed on the plot (string)  %Y%m%dz%d%b%Y-VALIDZ, z , inithours: INITz , valid: )rrr r%g8@rr z, Forecast Day z(Hour )z Forecast Days ,z(Hours )lowerdatetimestrptimestrftimesub_util get_init_hourintreplacestrzfillappendsortjoinget_valid_hourinit_hrlen)rE date_type start_dateend_datedate_type_hr_list other_hr_listZforecast_hour_listr(Zdate_plot_name start_date_dt end_date_dtZtitle_other_hr_listZ date_type_hr forecast_hourZother_hrZforecast_day_listZ forecast_dayrFrFrGget_dates_plot_names     zPlotSpecs.get_dates_plot_namec Cs||dd|dd||dd}|ddkrYd d tt|d t|d t|d t|d D}dd tt|dt|dt|dt|dD}n@|ddkrdd tt|dt|dt|dt|dD}dd tt|d t|d t|d t|d D}|jdvr|dg}n|d}|ddkr|dd|d}n|d}|jdvr|d} n|d} |jdvrd } n|d!} |dd"kr|dd#vrd } |||| }|d$d%|d&}| d kr|d'| d$|}t|d!d(d)} |dd*kr)t| d+d,} |d-t| d.}n|dd/vrBt| d0d,} |d-t| d.}nl|dd1kr`t| d2d3d4d5} |d-t| d6}nN|dd7kr|dd8krt| d9d:}t||krt|}|d-t|d;}n#|dd}|dd?kr|d$d@|dA}|d| |d|dB|dC||||j}|S)Da! Construct the title for the plot Args: plot_info_dict - plot information dictionary (strings) date_info_dict - date information dictionary (strings) units - variable units (string) Returns: plot_title - full plot title that will be displayed on the plot (string) rfz - gridrhr rrcSg|] }t|ddqSrrrr.0hrrFrFrG zz,PlotSpecs.get_plot_title..valid_hr_start valid_hr_end valid_hr_inccSrrrrrFrFrGrr init_hr_start init_hr_end init_hr_incrcSrrrrrFrFrGrrcSrrrrrFrFrGrrrr$r'rrforecast_hours fcst_var_name HGT_DECOMP_ interp_method)r$r% vert_profilefcst_var_level)r'rNAfcst_var_threshCAPEr^rPrZrTr(rrrNZAPCPgehWQ(?rIz (z in))ZSNOD_A24Z WEASD_A24go_C@ZDPTgfffffq@ r z F)ZHGTZCEILINGg s@r z kft)ZVISgp\D?z mile) NBRHD_SQUAREzNeighborhood Points: interp_pointsrr) rgrrangerr(rlrKroundrr)rEplot_info_dictdate_info_dictunitsZ plot_titlerrZ fhr_for_titleZvar_name_for_titleZvar_level_for_titleZvar_thresh_for_titleZ thresh_valueZ thresh_inZthresh_FZ thresh_kftZ thresh_milerFrFrGget_plot_titlegs                              zPlotSpecs.get_plot_titlecCs\d}|ddkr d}n|d}|ddkr*ttt|d}|dd t|}d t|vrK|d d krKt|d \}}|d| d d }|d} |ddkre| d|d dd dd} |d dd d d } t j |dd} t j |dd} t| |  dd} dt| d}|j dkrd}nG|j dkrd}n?|j dkrd}n7|j d krd!}n/|j d"krd#}n'|j d$krd%}n|j d&krd'}n|j d(krd)}n|j d*krd+}n|j dd}|j d,vr|d-}t|d.}|t|d/kr|t|d0}|t|d17}|t|d/ks|d2}|j d3vr0|dd4|d5d6}n(|j dkrG|ddd7d8|d9D}n|dd4t|d9d:d6}|d;}idd?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]id^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~dddddd}|dt|vr||d}n|d}d|d |d | d| d |d |d |d|d}tj||}|ddkr,| dd dd}|ddvr,| dd}|S)a! Construct the full path to save the plot Args: image_dir - full path to directory of where to save (string) plot_info_dict - plot information dictionary (strings) date_info_dict - date information dictionary (strings) Returns: image_path - full path of the name the plot will be saved as (string) Z subseasonalrfr]Zctcrrrrwidthrr.prrZWV1_rrrrrriQr lastdaysrZ timeseriesrrZfhrmeanr Zleaddater%Zvertprof_fhrmeanr'Zperfdiar$ZvertprofrZ threshmeanrZvhrmean)rrrr$r%r r'r_validrrrrrrfrrIcSsg|] }d|dqS)rrI)r)rrrFrFrGr2sz.PlotSpecs.get_savefig_name..rrrmZalaskaroZbuk_aplrnZ antarcticrpZarcticrqZal_mdrrrZ buk_conusrtZ buk_conus_ersZ buk_conus_cruZ buk_conus_srvZ buk_conus_wrwZbuk_cplrxZbuk_dsryZep_mdrrzZglbr|Zbuk_grbr}Zbuk_grlkZ MezqutialZbuk_mezr~Zbuk_matlrZn60rZnaorZnhemrZbuk_nerZbuk_nplrZnporZbuk_nrkrZbuk_npwrZbuk_pswrZbuk_prarZs60rZsaorZshemrZbuk_serZbuk_swrZbuk_splZspoZbuk_srkZtropicsZhawaii)rrrrrzevs.z.pngrZ_z0Z_l0Z_p90_0Z_l90rz_gt0||)rnpsqrtrKrrcrdr format_threshrrr total_secondsr(rrospathr)rEZ image_dirrrZcomponent_savefig_nameZmetric_savefig_nameZnwidth thresh_symbol thresh_letterZparameter_savefig_nameZlevel_savefig_namerrndaysZndays_savefig_nameZplot_type_savefig_nameZvalid_hrZgrid_savefig_nameZregion_savefig_dictZregion_savefig_nameZ savefig_nameZ image_pathrFrFrGget_savefig_names                           !"#(   zPlotSpecs.get_savefig_namecCsd}|dkr,|dkr,|dkr||d}||d}nd|dkr+||d}||d}nS|d krV|dkrV|dkrE||d}||d }n:|dkrU||d }||d }n)|d kr|d kr|dkro||d }||d }n|dkr||d }||d }|||fS)a! Get locations for the logos Args: position - side of image (string, "left" or "right") x_figsize - image size in x direction (float) y_figsize - image size in y direction(float) dpi - image dots per inch (float) Returns: x_loc - logo position in x direction (float) y_loc - logo position in y direction (float) alpha - alpha value (float) rr#g~jt?rightrrg{Gz?gtV?rg= ףp=?rF)rEpositionZ x_figsizeZ y_figsizeZdpialphaZx_locZy_locrFrFrGget_logo_locationzs2          zPlotSpecs.get_logo_locationc Cs|dvr#tjj}|ttdddtddd}tjj d|}ntjj }|dvr1|}||fS|dkr:tjj }ntjj }|ttdd dtd dd}tjj d |}||fS) z! Get colormaps for contour plots Args: stat - statistic name (string) Returns: subplot0_cmap - colormap for subplot 0 subplotsN_cmap - colormap for other subplots rPrZrUr333333?rffffff?r Z cmap_biasr^g333333?gffffff?Z cmap_diff) rJcmZPiYG_rrrlinspacerLcolorsZLinearSegmentedColormap from_listZBuPu_rZbwrZbwr_r)rErfZcmap_bias_originalZ colors_biasZ subplot0_cmapZsubplotsN_cmapZcmap_diff_originalZ colors_diffrFrFrGget_plot_colormapss.    zPlotSpecs.get_plot_colormapscsXtt|t|krtt|}t|}n t|}dt|}|dkr8||d}||d}n|dkrI||d}||d}n|}|}|dkr`t|dd}t|dd} nt|dd}t|dd} d} |d | dtjfd d t| Dtd } tj| dd td d} t| d d d| } |dkr| |} | S)a! Get contour levels for plotting levels center on a certain value Args: data - array of data to be contoured center_value - center value of the levels (integer) spacing - float for spacing for power function, value of 1.0 gives evenly spaced contour intervals Returns: center_clevels - array of contour levels rd皙?rr r rrr cs g|] }d|qSrrFridxspacingspanrFrGr z9PlotSpecs.get_centered_contour_levels..dtypeN) rabsnanminnanmaxrarrayrrKr)rEdata center_valuer cmaxZcminZ clevels_cmaxZ clevels_cminZclevels_round_cminZclevels_round_cmaxstepsposnegZcentered_clevelsrFrrGget_centered_contour_levelss:      z%PlotSpecs.get_centered_contour_levelsc sd}ttjg}|dkrd}tgd}nYtj|jspt|dkr,dn dkr3dnd |d krVd }d |d d}tjfddt|Dt d}n|dvrp|dvrad}n|dkrgd }d}| ||}d}ttjg} |dkrd}tgd} nt |t tjgkr|dvr|}|} |stt |ddddfD][} |dvr|| ddddf} t| dkrdn t| dkrdnd |dvrd}n|dkrd }n|| ddddf|} d}dtj| jsd}| | |} nq|||| fS)a! Get contour levels Args: stat - statistic name (string) subplot0_data - array of data for subplot 0 subplotsN_data - array of data for other subplots Returns: have_subplot0_levs - boolean if have valid values subplot 0 subplot0_levs - array of contour levels for subplot 0 have_subplotsN_levs - boolean if have valid values other subplots subplotsN_levs - array of contour levels for other subplots FrOT) rr rg333333?rg?rrgGz?r rg@rrg?r^r&r r cs g|] }d|qSrrFrrrr rFrGrr z5PlotSpecs.get_plot_contour_levels..r r)rPrZrrU) ggٿg333333ӿgɿggrrr rrg?rNr ) rrnanmamasked_invalidmaskallrrrKrshaper) rErfZ subplot0_dataZsubplotsN_dataZhave_subplot0_levsZ subplot0_levsrrZhave_subplotsN_levsZsubplotsN_levsNZ subplotN_datarFrrGget_plot_contour_levelss   z!PlotSpecs.get_plot_contour_levelscCsbgdgdgdgdgdd}|t|vr ||}|S|j|dd|d }|S) a^! Get list of levels that make up the vertical profile Args: vert_profile - name of vertical profile (string) Returns: vert_profile_levs - list of pressure levels that make up the vertical profile (strings) )P1000P925P850P700P500P400P300P250P200P150P100P50P20P10P5)r"r#r$r%r&)r&r'r(r)r*r+r,) r"r#r$r%r&r'r(r)r*r+r,)r,r-r.r/r0)rZltropZutropZtropZstratrizusing all levelsrrb)rErZvert_profile_levels_dictZvert_profile_levelsrFrFrGget_vert_profile_levelsGs  z!PlotSpecs.get_vert_profile_levelscCsrdddddddddddddddd ddd ddd ddd ddd dddddddddddd }|S)a! Get dictionary plot settings for models Args: Returns: marker_plot_settings_dict - dictionary of marker plotting specifications (strings) or&)marker markersizeP^XsDvr<dz $\spadesuit$>z $\clubsuit$) Zmarker1Zmarker2Zmarker3Zmarker4Zmarker5Zmarker6Zmarker7Zmarker8Zmarker9Zmarker10Zmarker11Zmarker12Zmarker13rF)rEZmarker_plot_settings_dictrFrFrGget_marker_plot_settingsds z"PlotSpecs.get_marker_plot_settingscCsdddddddddddddd d dd dd d d dd dddddd dddddd dddddd dddddd dddddd dddddd dddddddd }|S)a! Get dictionary plot settings for models Args: Returns: model_plot_settings_dict - dictionary of model plotting specifications (strings) #000000r2rsolidrIcolorr3r4Z linestyle linewidthz#56b4e9#1e3cffr8?#00dc00r5#e69f00z#696969r9z#8400c8r:z#d269c1z#f0e492z#aaaaaaNonerr) model1Zmodel2Zmodel3Zmodel4Zmodel5Zmodel6Zmodel7Zmodel8Zmodel9Zmodel10obsrF)rEZmodel_plot_settings_dictrFrFrGget_model_plot_settingss\ #z!PlotSpecs.get_model_plot_settingscCsddddddddd dddd d d dddd dd dddddddddddd dddd d d dddd dddddd dd dddd }|S)at! Get dictionary plot settings for forecast hours Args: Returns: forecast_hour_plot_settings_dict - dictionary of forecast hours plotting specifications (strings) z#fb2020r2rrArGrBrHr7rFrEr8rIr@r9) Zfhr_n1Zfhr_n2Zfhr_n3Zfhr_n4Zfhr024Zfhr048Zfhr072Zfhr120Zfhr240rF)rEZ forecast_hour_plot_settings_dictrFrFrGget_forecast_hour_plot_settingssL z)PlotSpecs.get_forecast_hour_plot_settingsN)__name__ __module__ __qualname__rHrNrgrlrrrrrrrr!r1r?rMrNrFrFrFrGrs("'t<Pn&&$,W /r) __doc__rLmatplotlib.pyplotpyplotrJrrCrnumpyrsubseasonal_utilrrrFrFrFrGs