OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
extract_band Namespace Reference

Functions

def copy_attribute (attr, in_group, out_group)
 
def copy_variable (src_var, src_grp, dest_grp)
 
def create_subgroup (in_parent_grp, in_grp_name, out_parent_grp, select_var=None)
 
def get_cla ()
 
def main ()
 
def process_main_dataset (in_dataset, band, out_dataset, attrs_to_skip=None)
 

Detailed Description

Program to extract a band (Variable) from one OBPG netCDF4 L2 file and create
a new file containing just that band.

The program is also meant to serve as an example of how OBPG files in netCDF4
format can be accessed and manipulated.

Helpful link:
    http://schubert.atmos.colostate.edu/~cslocum/netcdf_example.html

Function Documentation

◆ copy_attribute()

def extract_band.copy_attribute (   attr,
  in_group,
  out_group 
)
Copies the attribute named in attr from in_group to out_group.

The checks for unicode data are needed because netCDF stores its data in
Unicode. However, setncattr will prepend  "string" to the attributes if
they are unicode values.  A long discussion of this appears at:
     https://github.com/Unidata/netcdf4-python/pull/389

Definition at line 25 of file extract_band.py.

◆ copy_variable()

def extract_band.copy_variable (   src_var,
  src_grp,
  dest_grp 
)
Copies the netCDF4 Variable held in src_var from the src_grp Group to the
dest_grp Group.

Definition at line 41 of file extract_band.py.

◆ create_subgroup()

def extract_band.create_subgroup (   in_parent_grp,
  in_grp_name,
  out_parent_grp,
  select_var = None 
)
Creates a Group in out_grp using cur_grp_name as the name of the created
Group. Then recursively does the same for any subgroups of in_grp. If
select_var is not None, then only that Variable will be copied into the new
Group; otherwise, all Variables are copied.

Definition at line 56 of file extract_band.py.

◆ get_cla()

def extract_band.get_cla ( )
Returns the command line arguments: band to extract, input filename, and
output filename.

Definition at line 91 of file extract_band.py.

◆ main()

def extract_band.main ( )
Primary driver of the program; get command line arguments, check the files
specified and kick off the processing

Definition at line 107 of file extract_band.py.

◆ process_main_dataset()

def extract_band.process_main_dataset (   in_dataset,
  band,
  out_dataset,
  attrs_to_skip = None 
)
Copy the top level dimensions, Variables, and Attributes from in_dataset
to out_dataset. Copy Groups other than the 'geophysical_data' group. In the
'geophysical_data' Group, call copy_band to copy only the Variable named
in band.

Definition at line 147 of file extract_band.py.