Ejemplo n.º 1
0
    def check_ll_grid(self, remap_obj, lats, lons, lat_reverse=False, lon_shift=0):
        '''
        lat_reverse : True/False
        lon_shift   : number of shift points (used by np.roll)
        '''
        if lat_reverse: lats = lats[::-1]
        lons = np.roll(lons + (lons<0)*360, lon_shift)

        nlat, nlon = remap_obj.nlat, remap_obj.nlon
        ll_type = remap_obj.ll_type
        ref_lats, ref_lons = make_lats_lons(nlat, nlon, ll_type)

        aa_equal(np.rad2deg(ref_lats), lats, 13)
        aa_equal(np.rad2deg(ref_lons), lons, 13)
Ejemplo n.º 2
0
import netCDF4 as nc

from util.remap.cube_remap_matrix import make_lats_lons 




parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('nlon', type=int, help='number of longitude grid')
parser.add_argument('nlat', type=int, help='number of latitude grid')
parser.add_argument('ll_type', type=str, help='latlon grid type')
args = parser.parse_args()


nlat, nlon = args.nlat, args.nlon
lats, lons = make_lats_lons(nlat, nlon, args.ll_type)
lats_deg = np.rad2deg(lats)
lons_deg = np.rad2deg(lons)


fname = 'll_coord_%dx%d.nc'%(nlon, nlat)
ncf = nc.Dataset(fname, 'w', format='NETCDF3_CLASSIC') 
ncf.description = 'Latlon grid coordinates'
ncf.ll_type = args.ll_type

ncf.createDimension('nlon', nlon)
ncf.createDimension('nlat', nlat)

vlons = ncf.createVariable('lons', 'f8', ('nlon',))
vlons.units = 'degrees'
vlats = ncf.createVariable('lats', 'f8', ('nlat',))