Beispiel #1
0
    # Cycle through each raw file
    for file in os.listdir():
        if file[-7:] == "_raw.nc":
            print("Gridding: " + file)
            nc = Dataset(file, "r")

            lat = nc.variables["latitude"][:]
            lon = nc.variables["longitude"][:]
            ssh = nc.variables["sea_surface_height"][:]
            ice_conc = nc.variables["ice_concentration"][:]

            nc.close()

            # Grid dynamic ocean topography to a 1x0.5-degree grid
            # grid05(data, lon, lat, lat_resolution, lon_resolution)
            data = funct.grid05(ssh, lon, lat, float(lat_resolution), float(lon_resolution))
            grid_ssh = data["Grid"]
            grid_lon = data["Lon"]
            grid_lat = data["Lat"]

            data = funct.grid05(ice_conc, lon, lat, float(lat_resolution), float(lon_resolution))
            grid_ice = data["Grid"]

            # Make the longitudes between 0 and 360
            grid_ssh, grid_lon = funct.lon_convert(grid_lon, grid_ssh)
            grid_ice, grid_lon = funct.lon_convert(grid_lon, grid_ice)
            # grid_lon[grid_lon < 0] += 361

            # grid_ssh = grid_ssh[np.argsort(grid_lon), :]
            # grid_ice = grid_ice[np.argsort(grid_lon), :]
            # grid_lon = grid_lon[np.argsort(grid_lon)]
Beispiel #2
0
# Cycle through each raw file
for file in os.listdir():
    if file[-12:] == 'MDT_track.nc':
        print('Gridding: ' + file)
        nc = Dataset(file, 'r')
    
        lat = nc.variables['lat'][:]
        lon = nc.variables['lon'][:]
        mdt = nc.variables['mean_dynamic_topography'][:]
        ice_conc = nc.variables['sea_ice_concentration'][:]
    
        nc.close()
    
        # Grid mean dynamic topography to a 1-degree grid

        data = funct.grid05(mdt, lon, lat, 1)
        grid_mdt = data['Grid']
        grid_lon = data['Lon']
        grid_lat = data['Lat']
        
        data = funct.grid05(ice_conc, lon, lat, 1)
        grid_ice = data['Grid']
    
        # Put the data in a .nc file in /Users/jmh2g09/Documents/PhD/Data/Gridded

        os.chdir('/Users/jmh2g09/Documents/PhD/Data/Gridded/' + year + '/MDT')
    
        month = file[4:6]
        nc = Dataset(year + month + '_MDT.nc', 'w', format='NETCDF4_CLASSIC')

        nc.createDimension('lat', np.size(grid_lat))