src/coecms/cli/um.py
def era_sst(start_date, end_date, target_mask, output):
    """
    Create ancil files from ERA reanalysis data
    """

    um_grid = UMGrid.from_mask(target_mask)

    file_start = start_date - pandas.offsets.MonthBegin()
    file_end = end_date + pandas.offsets.MonthEnd()
    file_a = pandas.date_range(file_start,file_end,freq='MS')
    file_b = file_a + pandas.offsets.MonthEnd()

    dates = [f'{a.strftime("%Y%m%d")}_{b.strftime("%Y%m%d")}'
             for a,b in zip(file_a, file_b)]

    # Read and slice the source data
    tos = xarray.open_mfdataset(['/g/data1a/ub4/erai/netcdf/6hr/ocean/'
                                 'oper_an_sfc/v01/tos/'
                                 'tos_6hrs_ERAI_historical_an-sfc_'+d+'.nc'
                                 for d in dates],
                                 chunks={'time': 1,})
    sic = xarray.open_mfdataset(['/g/data1a/ub4/erai/netcdf/6hr/seaIce/'
                                 'oper_an_sfc/v01/sic/'
                                 'sic_6hrs_ERAI_historical_an-sfc_'+d+'.nc'
                                 for d in dates],
                                 chunks={'time': 1,})
    ds = xarray.Dataset({'tos': tos.tos, 'sic': sic.sic})
    ds = ds.sel(time=slice(start_date, end_date))

    weights = esmf_generate_weights(tos.tos.isel(time=0), um_grid, method='patch')
    newds = regrid(ds, weights=weights)

    print(newds)

    ancil = create_surface_ancillary(newds, {'tos': 24, 'sic': 31})
    ancil.to_file(output)

    Create ancil files from ERA reanalysis data
    
Create ancil files from ERA reanalysis data
Create ancil files from ERA reanalysis data
def era_sst(start_date, end_date, target_mask, output):
    um_grid = UMGrid.from_mask(target_mask)
    file_start = start_date - pandas.offsets.MonthBegin()
    file_end = end_date + pandas.offsets.MonthEnd()
    file_a = pandas.date_range(file_start,file_end,freq='MS')
    file_b = file_a + pandas.offsets.MonthEnd()
    dates = [f'{a.strftime("%Y%m%d")}_{b.strftime("%Y%m%d")}'
             for a,b in zip(file_a, file_b)]
    tos = xarray.open_mfdataset(['/g/data1a/ub4/erai/netcdf/6hr/ocean/'
                                 'oper_an_sfc/v01/tos/'
                                 'tos_6hrs_ERAI_historical_an-sfc_'+d+'.nc'
                                 for d in dates],
                                 chunks={'time': 1,})
    sic = xarray.open_mfdataset(['/g/data1a/ub4/erai/netcdf/6hr/seaIce/'
                                 'oper_an_sfc/v01/sic/'
                                 'sic_6hrs_ERAI_historical_an-sfc_'+d+'.nc'
                                 for d in dates],
                                 chunks={'time': 1,})
    ds = xarray.Dataset({'tos': tos.tos, 'sic': sic.sic})
    ds = ds.sel(time=slice(start_date, end_date))
    weights = esmf_generate_weights(tos.tos.isel(time=0), um_grid, method='patch')
    newds = regrid(ds, weights=weights)
    print(newds)
    ancil = create_surface_ancillary(newds, {'tos': 24, 'sic': 31})
    ancil.to_file(output)
def era_sst ( start_date , end_date , target_mask , output ) : um_grid = UMGrid . from_mask ( target_mask ) file_start = start_date - pandas . offsets . MonthBegin ( ) file_end = end_date + pandas . offsets . MonthEnd ( ) file_a = pandas . date_range ( file_start , file_end , freq = 'MS' ) file_b = file_a + pandas . offsets . MonthEnd ( ) dates = [ f'{a.strftime("%Y%m%d")}_{b.strftime("%Y%m%d")}' for a , b in zip ( file_a , file_b ) ] tos = xarray . open_mfdataset ( [ '/g/data1a/ub4/erai/netcdf/6hr/ocean/' 'oper_an_sfc/v01/tos/' 'tos_6hrs_ERAI_historical_an-sfc_' + d + '.nc' for d in dates ] , chunks = { 'time' : 1 , } ) sic = xarray . open_mfdataset ( [ '/g/data1a/ub4/erai/netcdf/6hr/seaIce/' 'oper_an_sfc/v01/sic/' 'sic_6hrs_ERAI_historical_an-sfc_' + d + '.nc' for d in dates ] , chunks = { 'time' : 1 , } ) ds = xarray . Dataset ( { 'tos' : tos . tos , 'sic' : sic . sic } ) ds = ds . sel ( time = slice ( start_date , end_date ) ) weights = esmf_generate_weights ( tos . tos . isel ( time = 0 ) , um_grid , method = 'patch' ) newds = regrid ( ds , weights = weights ) print ( newds ) ancil = create_surface_ancillary ( newds , { 'tos' : 24 , 'sic' : 31 } ) ancil . to_file ( output )
Create ancil files from ERA reanalysis data
Create ancil files from ERA reanalysis data
"""
    Create ancil files from ERA reanalysis data
    """ # Read and slice the source data
start_date
end_date
target_mask
output