o qg@s<ddlZddlZddlZddlmZddZddZddZd d Zd d Z d dZ ddZ ddZ ddZ ddZddZddZddZddZdd Zd!d"ZdEd#d$ZdEd%d&ZdEd'd(ZdEd)d*ZdEd+d,ZdEd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Z d;d<Z!d=d>Z"d?d@Z#dAdBZ$dCdDZ%dS)FN)PathcCBt|tstdddtd|stddtd|S)NzFFATAL ERROR: The provided VERIF_CASE ('{VERIF_CASE}') is not a string.z1 VERIF_CASE must be a string. Check the plotting configuration file.zCFATAL ERROR: The provided VERIF_CASE is empty. VERIF_CASE cannot be. empty. Check the plotting configuration file. isinstancestrprintsysexit) VERIF_CASErG/lfs/h1/ops/prod/packages/evs.v1.0.19/ush/global_ens/check_variables.pycheck_VERIF_CASE    rcCr)NzFFATAL ERROR: The provided VERIF_TYPE ('{VERIF_TYPE}') is not a string.z1 VERIF_TYPE must be a string. Check the plottingrrzCFATAL ERROR: The provided VERIF_TYPE is empty. VERIF_TYPE cannot berr) VERIF_TYPErrrcheck_VERIF_TYPErrcCsbt|tstdddtdtd|r'tdddd td|s/td d |S) NzFFATAL ERROR: The provided URL_HEADER ('{URL_HEADER}') is not a string.z1 URL_HEADER must be a string. Check the plottingrr[^A-Za-z0-9_\-\\]zEFATAL ERROR: The provided URL_HEADER string ('{URL_HEADER}') containsz/ invalid characters. URL_HEADER must be made of4 alphanumeric characters, hyphen, and/or underscore.' Check the plotting configuration file.z6The provided URL_HEADER is empty. Plot file names willz not include a header.rr r r r research) URL_HEADERrrrcheck_URL_HEADER,s*    rcCtt|tstdddtdt|s"td|ddt|s0td|d|s8td d |S) Nz@FATAL ERROR: The provided USH_DIR ('{USH_DIR}') is not a string.z. USH_DIR must be a string. Check the plottingrrz 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 r rexistsis_dir)USH_DIRrrr check_USH_DIRA$     r%cCr) NzDFATAL ERROR: The provided PRUNE_DIR ('{PRUNE_DIR}') is not a string.z0 PRUNE_DIR must be a string. Check the plottingrrz"WARNING: The provided PRUNE_DIR ('rrrz=The provided PRUNE_DIR is empty. Will store pruned stat filesr r!) PRUNE_DIRrrrcheck_PRUNE_DIRUr&r(cCr) NzBFATAL ERROR: The provided SAVE_DIR ('{SAVE_DIR}') is not a string.z/ SAVE_DIR must be a string. Check the plottingrrz!WARNING: The provided SAVE_DIR ('rrrz0The provided SAVE_DIR is empty. Will store plotsr r!)SAVE_DIRrrrcheck_SAVE_DIRir&r*cCspt|tstdddtdt|s"td|ddt|s0td|d|s6td |S) Nz@FATAL ERROR: The provided FIX_DIR ('{FIX_DIR}') is not a string.z. FIX_DIR must be a string. Check the plottingrrz WARNING: The provided FIX_DIR ('rrrzThe provided FIX_DIR is empty.r!)FIX_DIRrrr check_FIX_DIR}s     r,cCr) NzPFATAL ERROR: The provided OUTPUT_BASE_DIR ('{OUTPUT_BASE_DIR}') is not a string.z6 OUTPUT_BASE_DIR must be a string. Check the plottingrrz(WARNING: The provided OUTPUT_BASE_DIR ('rrrz?The provided OUTPUT_BASE_DIR is empty. Will look for stat filesr r!)OUTPUT_BASE_DIRrrrcheck_OUTPUT_BASE_DIRr&r.cCs8t|tstdddtd|stdd|S)NzHFATAL ERROR: The provided LOG_METPLUS ('{LOG_METPLUS}') is not a string.z2 LOG_METPLUS must be a string. Check the plottingrrz>WARNING: The provided LOG_METPLUS is empty. The logger will bez" the root logger of the hierarchy.r) LOG_METPLUSrrrcheck_LOG_METPLUSs  r0cCst|tstdddtdt|dvr(td|ddd d t|d vr) Nz>FATAL ERROR: The provided OBTYPE ('{OBTYPE}') is not a string.z, OBTYPE must be a string. Check the plottingrrr?zFFATAL ERROR: The provided OBTYPE ('{OBTYPE}') is not valid. OBTYPE mayr@rAr)OBTYPErrr check_OBTYPErDrFcCr>) Nz8FATAL ERROR: The provided RUN ('{RUN}') is not a string.z) RUN must be a string. Check the plottingrrr?z=FATAL ERROR: The provided RUN ('{RUN}') is not valid. RUN mayr@rAr)ZRUNrrr check_RUNrDrGcCsRt|tstdddtdt|dvr'tdddtd|S) NzDFATAL ERROR: The provided DATE_TYPE ('{DATE_TYPE}') is not a string.z/ DATE_TYPE must be a string. Check the plottingrr)INITVALIDzAFATAL ERROR: You provided the following DATE_TYPE: '{DATE_TYPE}'.z2 DATE_TYPE must be either 'INIT' or 'VALID'. Checkz! the plotting configuration file.r7) DATE_TYPErrrcheck_DATE_TYPEs   rKcCszt|tstdddtdtd|r'tdddd td|d kr3td d |Std dd|S)NzHFATAL ERROR: The provided EVAL_PERIOD ('{EVAL_PERIOD}') is not a string.z1 EVAL_PERIOD must be a string. Check the plottingrrrzGFATAL ERROR: The provided EVAL_PERIOD string ('{EVAL_PERIOD}') containsz0 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 forz possible presets).r) EVAL_PERIODrrrcheck_EVAL_PERIOD%s6    rNcCt|tstdddtdt|dks"t|dkry|dkry|sQtdd t|d d t|d d t|d d td|sdtddddtdt|dksytddddtd|S)NzDFATAL ERROR: The provided VALID_BEG ('{VALID_BEG}') is not a string.z/ VALID_BEG must be a string. Check the plottingrrrIvalid_hour_averagerLz@FATAL ERROR: The provided VALID_BEG is empty. Since DATE_TYPE is '', plot_type is', and EVAL_PERIOD isz', VALID_BEG cannot berzFATAL ERROR: The provided INIT_BEG ('{INIT_BEG}') is too shortz& or too long. INIT_BEG must be a daterVrW)INIT_BEGrJrMr\rrrcheck_INIT_BEGr^rbcCrO)NzBFATAL ERROR: The provided INIT_END ('{INIT_END}') is not a string.z. INIT_END must be a string. Check the plottingrrrHrPrLz?FATAL ERROR: The provided INIT_END is empty. Since DATE_TYPE isrQrRrSz', INIT_END cannot berz:FATAL ERROR: The provided INIT_END ('{INIT_END}') containsz* non-numeric characters. INIT_END may onlyrTrUz>FATAL ERROR: The provided INIT_END ('{INIT_END}') is too shortz& or too long. INIT_END must be a daterVrW)INIT_ENDrJrMr\rrrcheck_INIT_ENDr^rdcCst|tstdddtdt|dks"t|dkrX|sCtddt|d dt|d d tdtd |sStd dddtd|S)NzNFATAL ERROR: The provided FCST_INIT_HOUR ('{FCST_INIT_HOUR}') is not a string.z4 FCST_INIT_HOUR must be a string. Check the plottingrrrHrPzEFATAL ERROR: The provided FCST_INIT_HOUR is empty. Since DATE_TYPE isrQ' and plot type isz', FCST_INIT_HOUR cannot ber (^[ 0-9,]+)$z@FATAL ERROR: The provided FCST_INIT_HOUR ('{FCST_INIT_HOUR}') isz/ not valid. FCST_INIT_HOUR may contain numbers,rA rr r r r r8rXrr)FCST_INIT_HOURrJr\rrrcheck_FCST_INIT_HOUR:     ricCst|tstdddtdt|dks"t|dkrX|sCtddt|d dt|d d tdtd |sXtd dddtd|S)NzPFATAL ERROR: The provided FCST_VALID_HOUR ('{FCST_VALID_HOUR}') is not a string.z5 FCST_VALID_HOUR must be a string. Check the plottingrrrIrPzFFATAL ERROR: The provided FCST_VALID_HOUR is empty. Since DATE_TYPE isrQrez', FCST_VALID_HOUR cannot berrfzBFATAL ERROR: The provided FCST_VALID_HOUR ('{FCST_VALID_HOUR}') isz0 not valid. FCST_VALID_HOUR may contain numbers,rArg)FCST_VALID_HOURrJr\rrrcheck_FCST_VALID_HOURrjrlcCr)NzFFATAL ERROR: The provided FCST_LEVEL ('{FCST_LEVEL}') is not a string.z0 FCST_LEVEL must be a string. Check the plottingrrzCFATAL ERROR: The provided FCST_LEVEL is empty. FCST_LEVEL cannot berr) FCST_LEVELrrrcheck_FCST_LEVELrrncCr)NzDFATAL ERROR: The provided OBS_LEVEL ('{OBS_LEVEL}') is not a string.z/ OBS_LEVEL must be a string. Check the plottingrrzAFATAL ERROR: The provided OBS_LEVEL is empty. OBS_LEVEL cannot berr) OBS_LEVELrrrcheck_OBS_LEVELrrpcCpt|tstdddtd|stddtdtd|r6tdd d d d td|S) NzBFATAL ERROR: The provided var_name ('{var_name}') is not a string.z. var_name must be a string. Check the plottingrrz?FATAL ERROR: The provided var_name is empty. var_name cannot ber[^ A-Za-z0-9,_\-]zAFATAL ERROR: The provided var_name string ('{var_name}') containsz- invalid characters. var_name must be made of4 alphanumeric characters, hyphen, underscore, commas5 and/or spaces only. Check the plotting configurationr;r)var_namerrrcheck_var_name0     rvcCrq) NzJFATAL ERROR: The provided VX_MASK_LIST ('{VX_MASK_LIST}') is not a string.z2 VX_MASK_LIST must be a string. Check the plottingrrzGFATAL ERROR: The provided VX_MASK_LIST is empty. VX_MASK_LIST cannot berrrzIFATAL ERROR: The provided VX_MASK_LIST string ('{VX_MASK_LIST}') containsz1 invalid characters. VX_MASK_LIST must be made ofrsrtr;r) VX_MASK_LISTrrrcheck_VX_MASK_LIST6rwrycClt|tstdddtd|stddtdtd|r4tdd d d td|S) NzDFATAL ERROR: The provided FCST_LEAD ('{FCST_LEAD}') is not a string.z/ FCST_LEAD must be a string. Check the plottingrrzAFATAL ERROR: The provided FCST_LEAD is empty. FCST_LEAD cannot berz[^ 0-9,]zCFATAL ERROR: The provided FCST_LEAD string ('{FCST_LEAD}') containsz. invalid characters. FCST_LEAD must be made ofz/ numerics, commas and/or spaces only. Check the plotting configuration file.r) FCST_LEADrrrcheck_FCST_LEADM,     r}cCslt|tstdddtd|stddtdtd|r4tdd d dtd|S) NzDFATAL ERROR: The provided LINE_TYPE ('{LINE_TYPE}') is not a string.z/ LINE_TYPE must be a string. Check the plottingrrzAFATAL ERROR: The provided LINE_TYPE is empty. LINE_TYPE cannot berz [^ A-Za-z0-9]zCFATAL ERROR: The provided LINE_TYPE string ('{LINE_TYPE}') containsz. invalid characters. LINE_TYPE must be made ofz1 alphanumeric characters only. Check the plottingr) LINE_TYPErrrcheck_LINE_TYPEcr~rcCrz) Nz>FATAL ERROR: The provided INTERP ('{INTERP}') is not a string.z, INTERP must be a string. Check the plottingrrz;FATAL ERROR: The provided INTERP is empty. INTERP cannot berz[^A-Za-z0-9_\-]z=FATAL ERROR: The provided INTERP string ('{INTERP}') containsz+ invalid characters. INTERP must be made ofz5 alphanumeric characters, hyphens, and/or underscoresz- only. Check the plotting configuration file.r)INTERPrrr check_INTERPyr~rcCst|tstdddtdt|dvrt|s/tdd|dd d tdtd |rFtd d dddtdtd|r]tddddd tdtd|rttdddddtd|S)Nz@FATAL ERROR: The provided FCST_THRESH ('{FCST_THRESH}') is not az0 string. FCST_THRESH must be a string. Check ther{rCTCMCTCPCTNBRCTCz9FATAL ERROR: 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<>=.,! /-]zGFATAL ERROR: The provided FCST_THRESH string ('{FCST_THRESH}') containsz0 invalid characters. FCST_THRESH must be made of/ alphanumeric characters, comparison operators,7 periods, hyphens, commas and/or spaces only. Check the^((?![<=!>]).)*$z>FATAL ERROR: The provided FCST_THRESH string ('{FCST_THRESH}')- 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 r r8rr) FCST_THRESHrrrrcheck_FCST_THRESHsf          rcCsDt|tstdddtdt|dvr|s/tdd|dd d tdtd |rFtd d dddtdtd|r]tddddd tdtd|rttdddddtd|dd|ddkst t d|t t d|krtd|ddd |d!|S)"Nz>FATAL ERROR: The provided OBS_THRESH ('{OBS_THRESH}') is not az/ string. OBS_THRESH must be a string. Check ther{rrz8FATAL ERROR: The provided OBS_THRESH is empty. Since therz ', OBS_THRESHrrrzEFATAL ERROR: The provided OBS_THRESH string ('{OBS_THRESH}') containsz/ invalid characters. OBS_THRESH must be made ofrrrz,<=,>=,!=,==). OBS_THRESH must contain arrz. contains no numerics (digits 0-9). OBS_THRESHrrr; z[\s,]+z*WARNING: The provided OBS_THRESH string ('z')z. is not equivalent to the provided FCST_THRESHz string ('z').) rr r r r r8rrreplacerZsplit) OBS_THRESHrrrrrcheck_OBS_THRESHsz            rcCrq) NzsJ   $ # # " (.