コード例 #1
0
def do_layering(rap_downscale_dir, hrrr_downscale_dir, is_yellowstone=False):
    # Go through the RAP downscaled directories and find 
    # the corresponding HRRR downscaled file for each RAP
    # file.
    rap_file_paths = whf.get_filepaths(rap_downscale_dir)
    hrrr_file_paths = whf.get_filepaths(hrrr_downscale_dir)
    
    # Compare the YYYYMMDDHH/YYYYMMDDhh00.LDASIN_DOMAIN1.nc portions
    rap_files = []
    hrrr_files = []
    if is_yellowstone:    
        for rap in rap_file_paths:
             match = re.match(r'.*/RAP/[0-9]{8}/([0-9]{8}_i[0-9]{2}_f[0-9]{2,3}.*)',rap)
             rap_files.append(match.group(1)) 
        
        for hrrr in hrrr_file_paths:
             match = re.match(r'.*/HRRR/[0-9]{8}/([0-9]{8}_i[0-9]{2}_f[0-9]{2,3}.*)',hrrr)
             hrrr_files.append(match.group(1)) 
    else:
        for rap in rap_file_paths:
            match = re.match(r'.*/[0-9]{8}/([0-9]{8}_i[0-9]{2}_f[0-9]{2,3}.*)',rap)
            rap_files.append(match.group(1))
        for hrrr in hrrr_file_paths:
            match = re.match(r'.*/[0-9]{8}/([0-9]{8}_i[0-9]{2}_f[0-9]{2,3}.*)',hrrr)
            hrrr_files.append(match.group(1))

    # Find the matching files from each list
    files_to_layer = set(rap_files) & set(hrrr_files)
    for file in files_to_layer:
        srf.forcing("layer","RAP", file, "HRRR", file)
コード例 #2
0
def do_layering(rap_downscale_dir, hrrr_downscale_dir, is_yellowstone=False):
    # Go through the RAP downscaled directories and find 
    # the corresponding HRRR downscaled file for each RAP
    # file.
    rap_file_paths = whf.get_filepaths(rap_downscale_dir)
    hrrr_file_paths = whf.get_filepaths(hrrr_downscale_dir)
    
    # Compare the YYYYMMDDHH/YYYYMMDDhh00.LDASIN_DOMAIN1.nc portions
    rap_files = []
    hrrr_files = []
    if is_yellowstone:    
        for rap in rap_file_paths:
             match = re.match(r'.*/RAP/[0-9]{8}/([0-9]{8}_i[0-9]{2}_f[0-9]{2,3}.*)',rap)
             rap_files.append(match.group(1)) 
        
        for hrrr in hrrr_file_paths:
             match = re.match(r'.*/HRRR/[0-9]{8}/([0-9]{8}_i[0-9]{2}_f[0-9]{2,3}.*)',hrrr)
             hrrr_files.append(match.group(1)) 
    else:
        for rap in rap_file_paths:
            match = re.match(r'.*/[0-9]{8}/([0-9]{8}_i[0-9]{2}_f[0-9]{2,3}.*)',rap)
            rap_files.append(match.group(1))
        for hrrr in hrrr_file_paths:
            match = re.match(r'.*/[0-9]{8}/([0-9]{8}_i[0-9]{2}_f[0-9]{2,3}.*)',hrrr)
            hrrr_files.append(match.group(1))

    # Find the matching files from each list
    files_to_layer = set(rap_files) & set(hrrr_files)
    for file in files_to_layer:
        srf.forcing("layer","RAP", file, "HRRR", file)
コード例 #3
0
def do_regrid(dir_base, prod, data_files, is_yellowstone):
    """Do the regridding and downscaling of the product"""
    
    for file in data_files:
        # Use only the filename of the file, the 
        # regrid_data() is only expecting a file name.
        match = re.match(r'(.*)/([0-9]{8}_i[0-9]{2}_f[0-9]{2,3}.*)',file)
        file_only = match.group(2) 
        srf.forcing("../../parm/wrf_hydro_forcing.parm","regrid",prod,file_only)
コード例 #4
0
def do_regrid(config_file,dir_base, prod, data_files, is_yellowstone):
    """Do the regridding and downscaling of the product"""
    
    for file in data_files:
        # Use only the filename of the file, the 
        # regrid_data() is only expecting a file name.
        match = re.match(r'(.*)/([0-9]{8}_i[0-9]{2}_f[0-9]{2,3}.*)',file)
        file_only = match.group(2) 
        srf.forcing(config_file,"regrid",prod,file_only)
コード例 #5
0
    def _layer(self, parms, configFile):
        """ Perform layering

        NOTE: here is where returns status will be added and used
        
        Parameters
        ----------
        parms : Parms
          parameters
        configFile : string
          name of file with settings

        """
        path = self._issue.strftime("%Y%m%d%H") + "/"
        path += self._valid.strftime("%Y%m%d%H%M") + ".LDASIN_DOMAIN1.nc"
        WhfLog.info("LAYERING %s ", path)
        srf.forcing(configFile, 'layer', 'HRRR', path, 'RAP', path)
        WhfLog.info("DONE LAYERING file=%s", path)
コード例 #6
0
    def _layer(self, parms, configFile):
        """ Perform layering

        NOTE: here is where returns status will be added and used
        
        Parameters
        ----------
        parms : Parms
          parameters
        configFile : string
          name of file with settings

        """        
        path = self._issue.strftime("%Y%m%d%H") + "/"
        path += self._valid.strftime("%Y%m%d%H%M") + ".LDASIN_DOMAIN1.nc"
        WhfLog.info("LAYERING %s ", path)
        srf.forcing(configFile, 'layer', 'HRRR', path, 'RAP', path)
        WhfLog.info("DONE LAYERING file=%s", path)
コード例 #7
0
def regrid(fname, fileType, configFile):
   """Invoke regridding/downscaling 
       
   Parameters
   ----------
   fname: str
      name of file to regrid and downscale, with yyyymmdd parent dir
   fileType: str
      HRRR, RAP, ... string
   configFile : str
      configuration file with all settings

   Returns
   -------
   None

   """

   WhfLog.info("REGRIDDING %s DATA, file=%s", fileType, fname)
   try:
      if (fileType == 'HRRR'):
         srf.forcing(configFile, 'regrid', 'HRRR', fname[9:])
         # special case, if it is a 0 hour forecast, do double regrid
         regridIfZeroHr(configFile, fileType, fname)
      elif (fileType == 'RAP'):
         srf.forcing(configFile, 'regrid', 'RAP', fname[9:])
         # special case, if it is a 0 hour forecast, do double regrid
         regridIfZeroHr(configFile, fileType, fname)
      elif (fileType == 'GFS'):
         mrf.forcing(configFile, 'regrid', 'GFS', fname[9:])
      elif (fileType == 'MRMS'):
         aaf.forcing(configFile, 'regrid', 'MRMS', fname[9:])
      else:
         WhfLog.info("ERROR REGRIDDING %s DATA, file=%s", fileType, fname)
         raise InvalidArgumentError("Unknown file type " + fileType)
   except ZeroHourReplacementError as z:
      WhfLog.info("ERROR REGRIDDING: %s", z)
      WhfLog.info("Remove this forecast from state and continue")
      return
   except:
      WhfLog.info("ERROR REGRIDDING %s DATA, file=%s", fileType, fname)
      raise

   WhfLog.info("DONE REGRIDDING %s DATA, file=%s", fileType, fname)