47
47
from typing import Final , Literal , cast , get_args
48
48
49
49
import click
50
+ import datatree
50
51
import pandas as pd
51
- import xarray as xr
52
52
from loguru import logger
53
53
from pm_tb_data ._types import Hemisphere
54
54
59
59
)
60
60
from seaice_ecdr .cli .util import datetime_to_date
61
61
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
64
62
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
65
65
from seaice_ecdr .util import (
66
66
date_range ,
67
67
find_standard_monthly_netcdf_files ,
68
- get_intermediate_output_dir ,
68
+ get_complete_output_dir ,
69
69
get_num_missing_pixels ,
70
70
)
71
71
@@ -220,7 +220,7 @@ def get_error_code(
220
220
221
221
def get_pixel_counts (
222
222
* ,
223
- ds : xr . Dataset ,
223
+ ds : datatree . DataTree ,
224
224
product : Product ,
225
225
hemisphere : Hemisphere ,
226
226
ancillary_source : ANCILLARY_SOURCES = "CDRv5" ,
@@ -256,10 +256,12 @@ def get_pixel_counts(
256
256
continue
257
257
258
258
flag_value = flag_value_for_meaning (
259
- var = ds .surface_type_mask ,
259
+ var = ds .cdr_supplementary . surface_type_mask ,
260
260
meaning = flag ,
261
261
)
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
+ )
263
265
surf_value_counts [flag ] = num_flag_pixels
264
266
265
267
# Number of oceanmask (invalid ice mask) pixels
@@ -335,7 +337,7 @@ def make_validation_dict(
335
337
date : dt .date ,
336
338
hemisphere : Hemisphere ,
337
339
) -> dict :
338
- ds = xr . open_dataset (data_fp )
340
+ ds = datatree . open_datatree (data_fp )
339
341
340
342
pixel_counts = get_pixel_counts (
341
343
ds = ds ,
@@ -378,7 +380,7 @@ def validate_outputs(
378
380
* error_seaice_{n|s}_daily_{start_year}_{end_year}.csv. Contains the
379
381
following fields: [year, month, day, error_code]
380
382
"""
381
- intermediate_output_dir = get_intermediate_output_dir (
383
+ complete_output_dir = get_complete_output_dir (
382
384
base_output_dir = base_output_dir ,
383
385
hemisphere = hemisphere ,
384
386
)
@@ -404,12 +406,12 @@ def validate_outputs(
404
406
if product == "daily" :
405
407
for date in date_range (start_date = start_date , end_date = end_date ):
406
408
platform = PLATFORM_CONFIG .get_platform_by_date (date )
407
- data_fp = get_ecdr_filepath (
409
+ data_fp = get_complete_daily_filepath (
408
410
date = date ,
409
411
platform_id = platform .id ,
410
412
hemisphere = hemisphere ,
411
413
resolution = VALIDATION_RESOLUTION ,
412
- intermediate_output_dir = intermediate_output_dir ,
414
+ complete_output_dir = complete_output_dir ,
413
415
is_nrt = False ,
414
416
)
415
417
@@ -447,8 +449,8 @@ def validate_outputs(
447
449
else :
448
450
periods = pd .period_range (start = start_date , end = end_date , freq = "M" )
449
451
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 ,
452
454
)
453
455
454
456
results = find_standard_monthly_netcdf_files (
0 commit comments