Skip to content

Commit 98d4753

Browse files
committed
Update validation code for new final outputs
Note that this does not include any validation of the amsr2 data.
1 parent ad25cb5 commit 98d4753

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

seaice_ecdr/validation.py

+15-13
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
from typing import Final, Literal, cast, get_args
4848

4949
import click
50+
import datatree
5051
import pandas as pd
51-
import xarray as xr
5252
from loguru import logger
5353
from pm_tb_data._types import Hemisphere
5454

@@ -59,13 +59,13 @@
5959
)
6060
from seaice_ecdr.cli.util import datetime_to_date
6161
from seaice_ecdr.constants import DEFAULT_BASE_OUTPUT_DIR
62-
from seaice_ecdr.intermediate_daily import get_ecdr_filepath
63-
from seaice_ecdr.intermediate_monthly import get_intermediate_monthly_dir
6462
from seaice_ecdr.platforms import PLATFORM_CONFIG
63+
from seaice_ecdr.publish_daily import get_complete_daily_filepath
64+
from seaice_ecdr.publish_monthly import get_complete_monthly_dir
6565
from seaice_ecdr.util import (
6666
date_range,
6767
find_standard_monthly_netcdf_files,
68-
get_intermediate_output_dir,
68+
get_complete_output_dir,
6969
get_num_missing_pixels,
7070
)
7171

@@ -220,7 +220,7 @@ def get_error_code(
220220

221221
def get_pixel_counts(
222222
*,
223-
ds: xr.Dataset,
223+
ds: datatree.DataTree,
224224
product: Product,
225225
hemisphere: Hemisphere,
226226
ancillary_source: ANCILLARY_SOURCES = "CDRv5",
@@ -256,10 +256,12 @@ def get_pixel_counts(
256256
continue
257257

258258
flag_value = flag_value_for_meaning(
259-
var=ds.surface_type_mask,
259+
var=ds.cdr_supplementary.surface_type_mask,
260260
meaning=flag,
261261
)
262-
num_flag_pixels = int((ds.surface_type_mask == flag_value).sum())
262+
num_flag_pixels = int(
263+
(ds.cdr_supplementary.surface_type_mask == flag_value).sum()
264+
)
263265
surf_value_counts[flag] = num_flag_pixels
264266

265267
# Number of oceanmask (invalid ice mask) pixels
@@ -335,7 +337,7 @@ def make_validation_dict(
335337
date: dt.date,
336338
hemisphere: Hemisphere,
337339
) -> dict:
338-
ds = xr.open_dataset(data_fp)
340+
ds = datatree.open_datatree(data_fp)
339341

340342
pixel_counts = get_pixel_counts(
341343
ds=ds,
@@ -378,7 +380,7 @@ def validate_outputs(
378380
* error_seaice_{n|s}_daily_{start_year}_{end_year}.csv. Contains the
379381
following fields: [year, month, day, error_code]
380382
"""
381-
intermediate_output_dir = get_intermediate_output_dir(
383+
complete_output_dir = get_complete_output_dir(
382384
base_output_dir=base_output_dir,
383385
hemisphere=hemisphere,
384386
)
@@ -404,12 +406,12 @@ def validate_outputs(
404406
if product == "daily":
405407
for date in date_range(start_date=start_date, end_date=end_date):
406408
platform = PLATFORM_CONFIG.get_platform_by_date(date)
407-
data_fp = get_ecdr_filepath(
409+
data_fp = get_complete_daily_filepath(
408410
date=date,
409411
platform_id=platform.id,
410412
hemisphere=hemisphere,
411413
resolution=VALIDATION_RESOLUTION,
412-
intermediate_output_dir=intermediate_output_dir,
414+
complete_output_dir=complete_output_dir,
413415
is_nrt=False,
414416
)
415417

@@ -447,8 +449,8 @@ def validate_outputs(
447449
else:
448450
periods = pd.period_range(start=start_date, end=end_date, freq="M")
449451
for period in periods:
450-
monthly_dir = get_intermediate_monthly_dir(
451-
intermediate_output_dir=intermediate_output_dir,
452+
monthly_dir = get_complete_monthly_dir(
453+
complete_output_dir=complete_output_dir,
452454
)
453455

454456
results = find_standard_monthly_netcdf_files(

0 commit comments

Comments
 (0)