Closed ReubenHill closed 1 month ago
Adds a test file for the logarithm variable transform.
build-group=https://github.com/JCSDA-internal/ufo/pull/3445
Python script to generate test file for logarithm variable transform:
import netCDF4 as nc import numpy as np def logarithm_test_files_gen(): missing = -3.3687952621450501176e38 # jedi's missing value ob = np.linspace(-1.0, 5.0, 7) nlocs = len(ob) ob[-1] = missing missing_idxs = [0, 1, 6] lnob = np.log(ob) log10ob = np.log10(ob) log2ob = np.log2(ob) log1p5ob = np.log(ob) / np.log(1.5) lnob[missing_idxs] = missing log10ob[missing_idxs] = missing log2ob[missing_idxs] = missing log1p5ob[missing_idxs] = missing # Write observation file err = np.ones(nlocs) # arbitrary fileobs = nc.Dataset("logarithm_transform_obs.nc4", "w") fileobs._ioda_layout = "ObsGroup" fileobs._ioda_layout_version = 0 fileobs.date_time = "20200101T0000Z" Location = fileobs.createDimension("Location", nlocs) loc = fileobs.createVariable("Location", "f4", ("Location")) lat = fileobs.createVariable("MetaData/latitude", "f4", ("Location")) lon = fileobs.createVariable("MetaData/longitude", "f4", ("Location")) datetime = fileobs.createVariable("MetaData/dateTime", "i8", ("Location")) datetime.units = "seconds since 1970-01-01T00:00:00Z" loc[:] = 0 lat[:] = 0 lon[:] = 0 datetime[:] = 1577836800 # Variables MDO = fileobs.createVariable("MetaData/logMe", "f4", ("Location")) MDO[:] = ob OT = fileobs.createVariable("ObsValue/airTemperature", "f4", ("Location")) OT[:] = ob OTE = fileobs.createVariable("ObsError/airTemperature", "f4", ("Location")) OTE[:] = err OP = fileobs.createVariable("ObsValue/pressure", "i4", ("Location")) OP[:] = np.zeros(nlocs) # Arbitrary - for testing if derived is used ODP = fileobs.createVariable("DerivedObsValue/pressure", "f4", ("Location")) ODP[:] = ob OPE = fileobs.createVariable("ObsError/pressure", "f4", ("Location")) OPE[:] = err # Reference transformed values TRLnT = fileobs.createVariable("TestReferenceLn/airTemperature", "f4", ("Location")) TRLnT[:] = lnob TR10T = fileobs.createVariable( "TestReferenceLog10/airTemperature", "f4", ("Location") ) TR10T[:] = log10ob TR2T = fileobs.createVariable( "TestReferenceLog2/airTemperature", "f4", ("Location") ) TR2T[:] = log2ob TR1p5T = fileobs.createVariable( "TestReferenceLog1p5/airTemperature", "f4", ("Location") ) TR1p5T[:] = log1p5ob TRLnMDO = fileobs.createVariable("TestReferenceLn/logMe", "f4", ("Location")) TRLnMDO[:] = lnob TR10MDO = fileobs.createVariable("TestReferenceLog10/logMe", "f4", ("Location")) TR10MDO[:] = log10ob TR2MDO = fileobs.createVariable("TestReferenceLog2/logMe", "f4", ("Location")) TR2MDO[:] = log2ob TR1p5MDO = fileobs.createVariable("TestReferenceLog1p5/logMe", "f4", ("Location")) TR1p5MDO[:] = log1p5ob TR1p5DP = fileobs.createVariable("TestReferenceLog1p5/pressure", "f4", ("Location")) TR1p5DP[:] = log1p5ob fileobs.close() if __name__ == "__main__": logarithm_test_files_gen()
N/A
Expected impact on downstream repositories: None.
Description
Adds a test file for the logarithm variable transform.
build-group=https://github.com/JCSDA-internal/ufo/pull/3445
Python script to generate test file for logarithm variable transform:
Issue(s) addressed
N/A
Dependencies
build-group=https://github.com/JCSDA-internal/ufo/pull/3445
Impact
Expected impact on downstream repositories: None.
Checklist