Cleaning Module: swepy.process

The process module in SWEpy is meant to help you smooth erroneous spikes in SWE time series generated in the resampling process and through the inherent error associated with passive microwave sensors.

swepy.process.apply_filter(cube)

Function to apply the filter function in a parralel fashion Makes use of a Pool to process on every available core

Parameters

cube (np.array) – numpy array of data, should be 3d (x,x,x)

swepy.process.get_array(file, downsample=True)

Take 19H and 37H netCDF files, open and store tb data in np arrays

Parameters
  • file (str) – filename for 19H or 37H file

  • high (bool) – true = high resolution imagery (3.125km/6.25km) false = low resolution imagery (25km)

swepy.process.mask_ocean_winter(swe_matrix, day=0, nclasses=3)

Use a winter day to mask ocean pixels out of coastal imagery in arctic.

There is a clear difference between winter land pixels and ocean pixels that classification can sort out for us using a simple jenks classification. Data should have already moved through “vector_clean” and “apply_filter”

Parameters
  • swe_matrix (np.array) – swe time cube

  • day (int) – julian date of time series to use for classification (should be winter)

  • nclasses (int) – number of classes to use in jenks classification, defaults to 3

swepy.process.pandas_fill(arr)

Given 2d array, convert to pd dataframe and ffill missing values in place

Parameters

arr (np.array) – Ideally time vector of swe cube

swepy.process.safe_subtract(tb19, tb37)

Check size of each file, often the 19 and 37 matrices are one unit off of eachother.

Chops the larger matrix to match the smaller matrix

swepy.process.save_file(metafile, array, outname)

Save processed array back out to a new netCDF file

Metadata is copied from the un-processed file, evertyhing but TB

Parameters
  • metafile (str) – old file to copy metadata from

  • array (np.array) – processed TB array

  • outname (str) – name for output file

swepy.process.vector_clean(cube)

Clean erroneous spikes out of 37Ghz cube

Parameters
  • cube (np.array(t,x,y)) – np array time cube of 37GHz tb data

  • Note ("cube" can be used with other arrays but is looking for patterns in 37H files) –