Skip to content
Snippets Groups Projects
Commit a4379f26 authored by tomrink's avatar tomrink
Browse files

inital commit

parent dcd55b9d
No related branches found
No related tags found
No related merge requests found
import xarray as xr
import numpy as np
from util.geos_nav import GEOSNavigation
from netCDF4 import Dataset
import pickle
def romio_to_fgf(filename, goes_e_w='EAST'):
ds = xr.open_dataset(filename, engine='cfgrib')
lons = ds['longitude']
lats = ds['latitude']
lons = lons.values
lats = lats.values
lat_array, lon_array = np.meshgrid(lats, lons, indexing='ij')
nav = GEOSNavigation()
if goes_e_w == 'EAST':
nav = GEOSNavigation()
elif goes_e_w == 'WEST':
nav = GEOSNavigation(sub_lon=-137.0)
cc, ll = nav.earth_to_lc_s(lon_array.flatten(), lat_array.flatten())
cc = cc.reshape(lon_array.shape)
ll = ll.reshape(lon_array.shape)
f = open('/home/rink/elems.pkl', 'wb')
pickle.dump(cc, f)
f.close()
f = open('/home/rink/lines.pkl', 'wb')
pickle.dump(ll, f)
f.close()
ds.close()
return cc, ll
def create_file(filename, fgf_elem, fgf_line):
dim_x_len = fgf_elem.shape[1]
dim_y_len = fgf_elem.shape[0]
rootgrp = Dataset(filename, 'w', format='NETCDF4')
dim_x = rootgrp.createDimension('romio_x', size=dim_x_len)
dim_y = rootgrp.createDimension('romio_y', size=dim_y_len)
romio_fgf_elems = rootgrp.createVariable('romio_fgf_elems', 'f4', ['romio_y', 'romio_x'])
romio_fgf_lines = rootgrp.createVariable('romio_fgf_lines', 'f4', ['romio_y', 'romio_x'])
romio_fgf_elems[:, :] = fgf_elem[:, :]
romio_fgf_lines[:, :] = fgf_line[:, :]
rootgrp.close()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment