o ogʌ@s,ddlZddlZddlZddlmZddZddZddZd d Zd d Z d dZ ddZ ddZ ddZ ddZddZddZddZdAddZdAdd ZdAd!d"ZdAd#d$ZdAd%d&ZdAd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Z d;d<Z!d=d>Z"d?d@Z#dS)BN)PathcC:t|tstd|ddd|stdd|S)NzThe provided VERIF_CASE ('') is not a string.z1 VERIF_CASE must be a string. Check the plotting configuration file.z6The provided VERIF_CASE is empty. VERIF_CASE cannot be. empty. Check the plotting configuration file. isinstancestrsysexit) VERIF_CASEr E/lfs/h1/ops/prod/packages/evs.v1.0.19/ush/analyses/check_variables.pycheck_VERIF_CASE  rcCr)NzThe provided VERIF_TYPE ('rz1 VERIF_TYPE must be a string. Check the plottingrz6The provided VERIF_TYPE is empty. VERIF_TYPE cannot berr) VERIF_TYPEr r rcheck_VERIF_TYPErrcCsbt|tstd|dddtd|r'td|ddd d |s/td d |S) NzThe provided IMG_HEADER ('rz1 IMG_HEADER must be a string. Check the plottingrz[^A-Za-z0-9_\-\\.]z!The provided IMG_HEADER string (' ') containsz/ invalid characters. IMG_HEADER must be made of4 alphanumeric characters, hyphen, and/or underscore.' Check the plotting configuration file.z6The provided IMG_HEADER is empty. Plot file names willz not include a header.rr r r researchprint) IMG_HEADERr r rcheck_IMG_HEADER-s&  rcCtt|tstd|dddt|s"td|ddt|s0td|d|s8td d |S) NzThe provided USH_DIR ('rz. USH_DIR must be a string. Check the plottingrz WARNING: The provided USH_DIR ('') does not exist on the current system.') is not a directory.z6The provided USH_DIR is empty. Will look for USH files" in the current working directory.rr r r rexistsris_dir)USH_DIRr r r check_USH_DIRB"    r%cCr) NzThe provided PRUNE_DIR ('rz0 PRUNE_DIR must be a string. Check the plottingrz"WARNING: The provided PRUNE_DIR ('rrrz=The provided PRUNE_DIR is empty. Will store pruned stat filesr r!) PRUNE_DIRr r rcheck_PRUNE_DIRVr&r(cCr) NzThe provided SAVE_DIR ('rz/ SAVE_DIR must be a string. Check the plottingrz!WARNING: The provided SAVE_DIR ('rrrz0The provided SAVE_DIR is empty. Will store plotsr r!)SAVE_DIRr r rcheck_SAVE_DIRjr&r*cCr) Nz$The provided STAT_OUTPUT_BASE_DIR ('rz; STAT_OUTPUT_BASE_DIR must be a string. Check the plottingrz-WARNING: The provided STAT_OUTPUT_BASE_DIR ('rrrzDThe provided STAT_OUTPUT_BASE_DIR is empty. Will look for stat filesr r!)STAT_OUTPUT_BASE_DIRr r rcheck_STAT_OUTPUT_BASE_DIR~r&r,cCs8t|tstd|ddd|stdd|S)NzThe provided LOG_TEMPLATE ('rz3 LOG_TEMPLATE must be a string. Check the plottingrz?WARNING: The provided LOG_TEMPLATE is empty. The logger will bez" the root logger of the hierarchy.rr r r r) LOG_TEMPLATEr r rcheck_LOG_TEMPLATEs r/cCst|tstd|dddt|dvr(td|ddd d t|d vrcCsRt|tstd|dddtd|s'td|dddd|S) NzThe provided MODELS ('rz, MODELS must be a string. Check the plottingrz(^[ A-Za-z0-9,\-_]+)$z') is not valid. MODELS mayz0 contain letters, numbers, hyphens, underscores,, commas, and spaces only. Check the plottingr<)MODELSr r r check_MODELSs  rAcCsRt|tstd|dddt|dvr'td|ddd |S) NzThe provided DATE_TYPE ('rz/ DATE_TYPE must be a string. Check the plottingr)INITVALIDz'You provided the following DATE_TYPE: 'r6z2 DATE_TYPE must be either 'INIT' or 'VALID'. Checkz! the plotting configuration file.)rr r r r7) DATE_TYPEr r rcheck_DATE_TYPEs rEcCs~t|tstd|dddtd|r'td|ddd d |d kr3td d |Stdddd|S)NzThe provided EVAL_PERIOD ('rz1 EVAL_PERIOD must be a string. Check the plottingrz[^A-Za-z0-9_\-\\]z"The provided EVAL_PERIOD string ('rz0 invalid characters. EVAL_PERIOD must be made ofrrTESTz2Since the EVAL_PERIOD is set to 'TEST', will use az custom INIT/VALID period.z6Since the EVAL_PERIOD is not set to 'TEST', will use az4 preset INIT/VALID period (check ush/settings.py forz1 possible presets). EVAL_PERIOD may be dealt withz# differently for spatial_map plots.r) EVAL_PERIODr r rcheck_EVAL_PERIODs6  rHcCt|tstd|dddt|dks"t|dkru|dkru|sMtdd t|d d t|d d t|d d |s`td|ddddt|dksutd|dddd|S)NzThe provided VALID_BEG ('rz/ VALID_BEG must be a string. Check the plottingrrCvalid_hour_averagerFz3The provided VALID_BEG is empty. Since DATE_TYPE is '', plot_type is', and EVAL_PERIOD isz', VALID_BEG cannot berrz+ non-numeric characters. VALID_BEG may only/ contain numeric characters. Check the plotting') is too shortz' or too long. VALID_BEG must be a date, in the form of YYYYMMDD. Check the plottingrr r r r7lowerisdigitlen) VALID_BEGrDrG plot_typer r rcheck_VALID_BEG L  rXcCrI)NzThe provided VALID_END ('rz/ VALID_END must be a string. Check the plottingrrCrJrFz3The provided VALID_END is empty. Since DATE_TYPE isrKrLrMz', VALID_END cannot berrz+ non-numeric characters. VALID_END may onlyrNrOrPz' or too long. VALID_END must be a daterQrR) VALID_ENDrDrGrWr r rcheck_VALID_END.rYr[cCrI)NzThe provided INIT_BEG ('rz. INIT_BEG must be a string. Check the plottingrrBrJrFz2The provided INIT_BEG is empty. Since DATE_TYPE isrKrLrMz', INIT_BEG cannot berrz* non-numeric characters. INIT_BEG may onlyrNrOrPz& or too long. INIT_BEG must be a daterQrR)INIT_BEGrDrGrWr r rcheck_INIT_BEGQrYr]cCrI)NzThe provided INIT_END ('rz. INIT_END must be a string. Check the plottingrrBrJrFz2The provided INIT_END is empty. Since DATE_TYPE isrKrLrMz', INIT_END cannot berrz* non-numeric characters. INIT_END may onlyrNrOrPz& or too long. INIT_END must be a daterQrR)INIT_ENDrDrGrWr r rcheck_INIT_ENDtrYr_cCt|tstd|dddt|dks"t|dkrT|s?tddt|d dt|d d td |sTtd|d ddd|S)NzThe provided FCST_INIT_HOUR ('rz4 FCST_INIT_HOUR must be a string. Check the plottingrrBrJz8The provided FCST_INIT_HOUR is empty. Since DATE_TYPE isrK' and plot type isz', FCST_INIT_HOUR cannot ber (^[ 0-9,]+)$') isz/ not valid. FCST_INIT_HOUR may contain numbers,r?rr r r r7rSrr)FCST_INIT_HOURrDrWr r rcheck_FCST_INIT_HOUR4  rfcCr`)NzThe provided FCST_VALID_HOUR ('rz5 FCST_VALID_HOUR must be a string. Check the plottingrrCrJz9The provided FCST_VALID_HOUR is empty. Since DATE_TYPE isrKraz', FCST_VALID_HOUR cannot berrbrcz0 not valid. FCST_VALID_HOUR may contain numbers,r?rd)FCST_VALID_HOURrDrWr r rcheck_FCST_VALID_HOURrgricCr)NzThe provided FCST_LEVEL ('rz0 FCST_LEVEL must be a string. Check the plottingrz6The provided FCST_LEVEL is empty. FCST_LEVEL cannot berr) FCST_LEVELr r rcheck_FCST_LEVELrrkcCr)NzThe provided OBS_LEVEL ('rz/ OBS_LEVEL must be a string. Check the plottingrz4The provided OBS_LEVEL is empty. OBS_LEVEL cannot berr) OBS_LEVELr r rcheck_OBS_LEVELrrmcCht|tstd|ddd|stddtd|r2td|d d d d d |S)NzThe provided var_name ('rz. var_name must be a string. Check the plottingrz2The provided var_name is empty. var_name cannot ber[^ A-Za-z0-9,_\-]zThe provided var_name string ('rz- invalid characters. var_name must be made of4 alphanumeric characters, hyphen, underscore, commas5 and/or spaces only. Check the plotting configurationr;r<)var_namer r rcheck_var_name*  rscCrn)NzThe provided VX_MASK_LIST ('rz2 VX_MASK_LIST must be a string. Check the plottingrz:The provided VX_MASK_LIST is empty. VX_MASK_LIST cannot berroz#The provided VX_MASK_LIST string ('rz1 invalid characters. VX_MASK_LIST must be made ofrprqr;r<) VX_MASK_LISTr r rcheck_VX_MASK_LISTrtrvcCdt|tstd|ddd|stddtd|r0td|d d d d |S) NzThe provided FCST_LEAD ('rz/ FCST_LEAD must be a string. Check the plottingrz4The provided FCST_LEAD is empty. FCST_LEAD cannot ber[^ 0-9,]z The provided FCST_LEAD string ('rz. invalid characters. FCST_LEAD must be made of/ numerics, commas and/or spaces only. Check the plotting configuration file.r<) FCST_LEADr r rcheck_FCST_LEAD&  r|cCsdt|tstd|ddd|stddtd|r0td|d d d d|S) NzThe provided LINE_TYPE ('rz/ LINE_TYPE must be a string. Check the plottingrz4The provided LINE_TYPE is empty. LINE_TYPE cannot berz [^ A-Za-z0-9]z The provided LINE_TYPE string ('rz. invalid characters. LINE_TYPE must be made ofz1 alphanumeric characters only. Check the plottingr<) LINE_TYPEr r rcheck_LINE_TYPE.r}rcCrw) NzThe provided INTERP ('rz, INTERP must be a string. Check the plottingrz.The provided INTERP is empty. INTERP cannot berz[^A-Za-z0-9_\-]zThe provided INTERP string ('rz+ invalid characters. INTERP must be made ofz5 alphanumeric characters, hyphens, and/or underscoresz- only. Check the plotting configuration file.r<)INTERPr r r check_INTERPDr}rcCst|tstd|dddt|dvrp|s+tdd|dd d td |rBtd |d ddddtd|rYtd |ddddd td|rptd |ddddd|S)NzThe provided FCST_THRESH ('r:z0 string. FCST_THRESH must be a string. Check therzCTCMCTCPCTNBRCTCz,The provided FCST_THRESH is empty. Since the provided line type is 'z', FCST_THRESH$ cannot be empty. Check the plottingr[^A-Za-z0-9<>=.,! /-]z"The provided FCST_THRESH string ('rz0 invalid characters. FCST_THRESH must be made of/ alphanumeric characters, comparison operators,7 periods, hyphens, commas and/or spaces only. Check the^((?![<=!>]).)*$')- does not contain a valid comparison operatorz. (<,>,<=,>=,!=,==). FCST_THRESH must contain a/ valid comparison operator. Check the plotting^((?![0-9]).)*$z/ contains no numerics (digits 0-9). FCST_THRESH/ must contain an integer or decimal in order to, be valid. Check the plotting configurationr;)rr r r r7rr) FCST_THRESHr~r r rcheck_FCST_THRESHZs\     rcCs<t|tstd|dddt|dvr|s+tdd|dd d td |rBtd |d ddddtd|rYtd |ddddd td|rptd |ddddd|dd|ddkstt d|tt d|krt d|ddd |d!|S)"NzThe provided OBS_THRESH ('r:z/ string. OBS_THRESH must be a string. Check therzrz+The provided OBS_THRESH is empty. Since therz ', OBS_THRESHrrrz!The provided OBS_THRESH string ('rz/ invalid characters. OBS_THRESH must be made ofrrrrrz- (<,>,<=,>=,!=,==). OBS_THRESH must contain arrz. contains no numerics (digits 0-9). OBS_THRESHrrr; z[\s,]+z*WARNING: The provided OBS_THRESH string ('z. is not equivalent to the provided FCST_THRESHz string ('z').) rr r r r7rrreplacerUsplitr) OBS_THRESHrr~r r rcheck_OBS_THRESHsp       rcCrn)NzThe provided STATS ('rz+ STATS must be a string. Check the plottingrz,The provided STATS is empty. STATS cannot berrozThe provided STATS string ('rz* invalid characters. STATS must be made ofrprqr;r<)STATSr r r check_STATSrtrcCs<t|tstd|ddd|stddd|S)Nz$The provided CONFIDENCE_INTERVALS ('rz: CONFIDENCE_INTERVALS must be a string. Check the plottingrz4WARNING: The provided CONFIDENCE_INTERVALS is empty.z1 Confidence intervals will not be plotted. Set toz2 'True' if confidence intervals should be plotted.r-)CONFIDENCE_INTERVALSr r rcheck_CONFIDENCE_INTERVALSs rcCsRt|tstd|dddtd|r'td|ddd d |S) NzThe provided INTERP_PTS ('rz0 INTERP_PTS must be a string. Check the plottingrrxz!The provided INTERP_PTS string ('rz/ invalid characters. INTERP_PTS must be made ofryrzr<)Z INTERP_PTSr r rcheck_INTERP_PTSs  r)N)$r loggingrpathlibrrrrr%r(r*r,r/r9r>rArErHrXr[r]r_rfrirkrmrsrvr|rrrrrrrr r r rsF   $ # # " (.