OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
drop_orbit_objects.py
Go to the documentation of this file.
1 def drop_orbit_objects(l1afile,l1arenav):
2  # drop orb_time,orb_pos and orb_vel from navigation_data group in the seahawk l1a file
3  # in preparation of adding updated navigation data to same variables
4  # Liang Hong, 3/11/2020
5  # Liang Hong, 2/19/2021, added missing group attributes to destination file
6  import netCDF4
7 
8  with netCDF4.Dataset(l1afile) as src, netCDF4.Dataset(l1arenav, "w") as dst:
9  # copy global attributes all at once via dictionary
10  dst.setncatts(src.__dict__)
11  # copy dimensions
12  for name, dimension in src.dimensions.items():
13  dst.createDimension(
14  name, (len(dimension) if not dimension.isunlimited() else None))
15  # copy all file data except for the excluded
16  for name, group in src.groups.items():
17  dst.createGroup(name)
18  dst[name].setncatts(src[name].__dict__)
19  for vname,variable in group.variables.items():
20  if vname.find('orb_')>-1:
21  continue
22  gvname = name+'/'+vname
23  x = dst.createVariable(gvname, variable.datatype, variable.dimensions)
24  # copy variable attributes all at once via dictionary
25  dst[gvname].setncatts(src[gvname].__dict__)
26  dst[gvname][:] = src[gvname][:]
27 
def drop_orbit_objects(l1afile, l1arenav)