def regrid(lat1,lon1,lats,lons,var,years): """ Interpolated on a 180x180 grid (latxlon) from CryoSat-2 using EASE2.0 100 km grid """ varn_re = np.reshape(var,(var.shape[0],(448*304))) varn = np.empty((var.shape[0],lats.shape[0],lons.shape[1])) print 'Completed: Start regridding process:' for i in xrange(varn.shape[0]): z = g((np.ravel(lat1),np.ravel(lon1)),varn_re[i,:], (lats,lons),method='linear') varn[i,:,:] = z print 'Completed: Year %s Regridding---' % (years[i]) print 'Completed: Done regridding process!' return varn
def regrid(lat1,lon1,lat2,lon2,var,years): """ Interpolated on selected grid. Reads PIOMAS in as 4d with [year,month,lat,lon] """ varn_re = np.reshape(var,(var.shape[0],var.shape[1],(120*360))) varn = np.empty((var.shape[0],var.shape[1],lat2.shape[0],lon2.shape[1])) print 'Completed: Start regridding process:' for i in xrange(varn.shape[0]): for j in xrange(varn.shape[1]): z = g((np.ravel(lat1),np.ravel(lon1)),varn_re[i,j,:],(lat2,lon2),method='linear') varn[i,j,:,:] = z print 'Completed: Year %s Regridding---' % (years[i]) return varn
def regrid(lat1, lon1, lats, lons, var, years): """ Interpolated on a 180x180 grid (latxlon) from CryoSat-2 using EASE2.0 100 km grid """ varn_re = np.reshape(var, (var.shape[0], (448 * 304))) varn = np.empty((var.shape[0], lats.shape[0], lons.shape[1])) print 'Completed: Start regridding process:' for i in xrange(varn.shape[0]): z = g((np.ravel(lat1), np.ravel(lon1)), varn_re[i, :], (lats, lons), method='linear') varn[i, :, :] = z print 'Completed: Year %s Regridding---' % (years[i]) print 'Completed: Done regridding process!' return varn
lat1,lon1,snc1 = piomasReader(directorydata1,'snow',years) ### Select month for data analysis (April) sitpa = sit1[:,3,:,:] sncpa = snc1[:,3,:,:] ### Select years for data analysis yearq = np.where(yearsp >= 2011)[0] sitpa = sitpa[yearq,:,:] sncpa = sncpa[yearq,:,:] #### Find PIOMAS values of CS2 lat/lons interpsit = [] interpsnc = [] for i in xrange(years.shape[0]): psit = g((lon1.flatten(),lat1.flatten()), sitpa[i,:,:].flatten(),(lonvals[i],latvals[i])) psnc = g((lon1.flatten(),lat1.flatten()), sncpa[i,:,:].flatten(),(lonvals[i],latvals[i])) interpsit.append(psit) interpsnc.append(psnc) print '\nCompleted: Interpolated year %s!' % years[i] ########################################################################### ########################################################################### ########################################################################### ### Save interpolated PIOMAS data directorytext = '/home/zlabe/Documents/Projects/CAAthickness/Data/' for i in xrange(years.shape[0]):
for i in range(days.shape[0]): filename = directorydata2 + 'jan_2018_%s.nc' % days[i] data = Dataset(filename, 'r') sic19[i, :, :] = data.variables['ice_conc'][:] latold2 = data.variables['lat'][:] lonold2 = data.variables['lon'][:] data.close() sic19[np.where(sic19 == -999)] = np.nan ### Calculate monthly average sicmean = np.nanmean(sic19, axis=0) #### Regrid data ak = g((np.ravel(latold2), np.ravel(lonold2)), sicmean.ravel(), (lat2, lon2), method='linear') def netcdfAlaska(lats, lons, var, directory): print('\n>>> Using netcdfAlaska function!') name = 'Alaska_SIC_Jan_2018.nc' filename = directory + name ncfile = Dataset(filename, 'w', format='NETCDF4') ncfile.description = 'January 2018 SIC from OSISAF ' \ 'interpolated on grid from' \ 'Alaska Sea Ice Atlas' ### Dimensions ncfile.createDimension('lat', var.shape[0])