Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions src/compo/mopitt_co_nc2ioda.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@


class mopitt(object):
def __init__(self, filenames):
def __init__(self, filenames, time_range):
self.filenames = filenames
self.time_range = time_range
self.varDict = defaultdict(lambda: defaultdict(dict))
self.outdata = defaultdict(lambda: DefaultOrderedDict(OrderedDict))
self.varAttrs = DefaultOrderedDict(lambda: DefaultOrderedDict(dict))
Expand Down Expand Up @@ -151,7 +152,15 @@ def _read(self):
ap_tc = ap_tc.astype('float32')

# set flag: rule out all anomalous data
flg = qa == 0
qaf = qa == 0

# date range to fit DA window
date_start = datetime.strptime(self.time_range[0], "%Y%m%d%H")
date_end = datetime.strptime(self.time_range[1], "%Y%m%d%H")
date_list = [datetime.strptime(date, "%Y-%m-%dT%H:%M:%SZ") for date in times]
tsf = [(date_i >= date_start) & (date_i < date_end) for date_i in date_list]

flg = np.logical_and(qaf, tsf)

if first:
# add metadata variables
Expand Down Expand Up @@ -230,10 +239,18 @@ def main():
help="path of IODA output file",
type=str, required=True)

optional = parser.add_argument_group(title='optional arguments')
optional.add_argument(
'-r', '--time_range',
help="extract a date range to fit the data assimilation window"
"format -r YYYYMMDDHH YYYYMMDDHH",
type=str, metavar=('begindate', 'enddate'), nargs=2,
default=('1970010100', '2170010100'))

args = parser.parse_args()

# Read in the MOPITT CO data
co = mopitt(args.input)
co = mopitt(args.input, args.time_range)

# setup the IODA writer
writer = iconv.IodaWriter(args.output, locationKeyList, DimDict)
Expand Down
3 changes: 2 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,8 @@ ecbuild_add_test( TARGET test_${PROJECT_NAME}_mopitt_co
netcdf
"${Python3_EXECUTABLE} ${CMAKE_BINARY_DIR}/bin/mopitt_co_nc2ioda.py
-i testinput/mopitt_co.he5
-o testrun/mopitt_co.nc"
-o testrun/mopitt_co.nc
-r 2021092903 2021092921"
mopitt_co.nc ${IODA_CONV_COMP_TOL_ZERO})

ecbuild_add_test( TARGET test_${PROJECT_NAME}_modis_aod
Expand Down
4 changes: 2 additions & 2 deletions test/testoutput/mopitt_co.nc
Git LFS file not shown