U Ó g©ã@s^dZddlZddlZddlZddlmZdddgZdd„Z d d „Z d d„Z d d„Z d d„Z dS)zî!Functions called automatically before a cycle is launched. This module contains utility functions for the hwrf.launcher.launch() prelaunch argument. These functions edit the configuration of an individual cycle before the cycle starts.éN)ÚjloggerÚprelaunch_ungribÚprelaunch_rsmcÚprelaunch_basincCsp| ddd¡}|jj}||krlt d||f¡| d||f¡| ddd¡| ddd¡| dd d¡d S) zA!Disables relocation and GSI if the wind is below some threshold.ÚconfigZmin_wind_for_initrz-Wind %d < %d so disabling GSI and relocation.zNWind %d<%d - run_gsi, run_relocation and run_ens_relocation overridden to "no"Úrun_gsiÚnoÚrun_relocationÚrun_ens_relocationN)ÚgetintÚsyndatÚwmaxrÚinfoÚset)ÚconfÚloggerÚ thresholdÚwind©rú;/lfs/h1/ops/prod/packages/hmon.v3.2.7/ush/hwrf/prelaunch.pyÚprelaunch_windsÿÿrcCsœ| dd¡}|s| d¡dS| ddd¡}| dd |d ¡}| dd |d ¡}|rt| d ||f¡| dd |¡|r˜| d||f¡| dd|¡dS)z¾!Changes the ungrib item and item2 based on the ensemble ID. This is used to ensure ensemble member 0 uses the GEFS control, which has a different item in the hwrf.input.DataCatalog.Ú prelaunchZensid_overridesz#Ensemble ID overrides are disabled.NrÚENSécÚungribz item_E%02dÚz item2_E%02dz&Overriding [ungrib] item=item_E%02d=%sÚitemz(Overriding [ungrib] item2=item2_E%02d=%sÚitem2)Úgetboolrr Úgetr)rrZ ens_overridesÚensrrrrrÚprelaunch_ensids  r!cCsX| dd¡}|s| d¡dStj |¡}| d¡}| d|d¡}|rT| dd|¡dS) aF!Change the ungrib table based on the year. Modifies the tbl entry in the [ungrib] section based on the year if a tbl$YEAR is available for the year of the cycle being run. @param conf the hwrf.config.HWRFConfig to modify @param logger the logging.Logger for log messages @param cycle the cycle being run.rÚungrib_overrideszUngrib overrides are disabled.Nztbl%YrrÚtbl)rrÚhwrfÚnumericsÚ to_datetimeÚstrftimerr)rrÚcycler"ÚcycZ tblYEARnameZ tblYEARvaluerrrr0s    cCsl| dd¡}|s| d¡dS|j}t|jƒ ¡}|jdd|d}tj  |¡s^|  d|f¡|  |¡dS)a¯!Modifies the configuration for the RSMC (JTWC, NHC, etc.) Modifies the configuration to work differently for JTWC and NHC storms. Searches for the rsmc_conf option in the [prelaunch] section for the name of a configuration file to read, and reads it if it exists. @param conf the hwrf.config.HWRFConfig to modify @param logger the logging.Logger for log messages @param cycle the cycle being run.rÚrsmc_overrideszRSMC overrides are disabled.Nz {rsmc_conf})ZRSMCz/%s: RSMC override file is empty or non-existent) rrr ÚstrÚcenterÚupperÚ strinterpÚprodutilÚfileopÚ isnonemptyÚwarningÚread)rrr(r*ÚvitZrsmcZrfilerrrrFs   ÿcCsÂ| dd¡}|s| d¡dS|j}|dkr:| d¡dS|jdd|d}|jdd|d}tj |¡r‚| d |f¡| |¡ns