slicing and aggregating
Slicing and aggregating are basic reductions of multi-dimensional data that you should be familiar with to work in this group. Slicing means to take one or many elements of a dimension (e.g., times, layers, rows, columns). Aggregating means to compute a function over more than one element of a dimension. This functionality is part of PseudoNetCDF via the -r and -s options. The -r option stands for reduce, meaning to reduce a dimensionality by aggregation. The -s option stands for slice meaning to select one or several members of a dimensions.
python -m PseudoNetCDF.pncgen -f [-v ] [-r ,] [-s ,[,[,]
- PseudoNetCDF is a free software for manipulating netcdf and netcdf-like objects
- is the file format and can be one of many things
- bpch - GEOS-Chem Binary Punch files
- geos - GEOS meteorology input files
- uamiv - CAMx input/output
- netcdf - a netcdf file
- ffi1001 - ICARTT file format
- path to input file
- path to input file
- is a dimension name. The available dimensions can be found by running python -m PseudoNetCDF.pncdump
- any python function
- a 0-based, inclusive starting index for subsetting a dimension
- a 0-based, exclusive ending index for subsetting a dimension
- increment between selections in the slice
- a comma separated list of variables to extract
Example Usage
Surface Layer
Command:
pncgen -f bpch -v IJ-AVG-\$_Ox -s layer47,0 -r time,mean ctm.bpch sample_surface_geos_chem_output.nc
Explanation:
Selects the Odd-Oxygen variable (IJ-AVG-\$_Ox) from GEOS-Chem file (-f bpch; ctm.bpch); selects the first layer (-s layer47,0); arithmetically averages across time (-r time,mean). This produces a average value for each latitudinal bin.
Notes:
Slicing always happens before aggregation.
Zonal Averaging
Command:
python -m PseudoNetCDF.pncgen -f bpch -v IJ-AVG-\$_Ox,layer48 -r longitude,mean -r time,mean ctm.bpch sample_zonal_geos_chem_output.nc
Explanation:
Selects the Odd-Oxygen and layer48 variables (IJ-AVG-\$_Ox,layer48) from GEOS-Chem file (-f bpch; ctm.bpch); arithmetically averages across the longitude (-r longitude,mean) and time (-r time,mean). This produces a average value for each latitudinal bin.
Notes:
Multiple slices or aggregations are specified by repeating the flag. Each function is applied serially.