Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mhs/das 2216/quick fixes #19

Merged
merged 25 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
bb7ebd8
DAS-1934: Most basic implementation to allow consistent grids
flamingbear Aug 28, 2024
d072bca
DAS-1934: Update comments and README for new grid validation.
flamingbear Aug 29, 2024
addf305
DAS-1934: Update changelog
flamingbear Aug 29, 2024
8150470
DAS-1934: Update changelog redux
flamingbear Aug 29, 2024
44589d8
DAS-1934: Update service version and address snyk vulnerabilities
flamingbear Aug 29, 2024
f9890f0
Update CHANGELOG.md
flamingbear Sep 1, 2024
ed0ff0e
DAS-1934: Fix release note extraction script.
flamingbear Sep 1, 2024
7622aa7
DAS-2216: Quick Fixes 1, 2 and 4
flamingbear Sep 9, 2024
b319a63
Merge remote-tracking branch 'origin/main' into mhs/DAS-2216/quick-fixes
flamingbear Sep 12, 2024
31c5bea
Merge branch 'main' into mhs/DAS-2216/quick-fixes
joeyschultz Sep 23, 2024
2a5a6ef
DAS-2216: Modify earthdata-varinfo config for quick fix 1
joeyschultz Oct 10, 2024
4477475
DAS-2216: Resolve unit tests that were failing due to quick fixes
joeyschultz Oct 10, 2024
404088c
DAS-2216: Update service version and CHANGELOG.
joeyschultz Oct 10, 2024
72223b9
Modify transpose_if_xdim_less_than_ydim to resolve mask array not bei…
joeyschultz Oct 16, 2024
656c858
Create notebook for PR testing and demo purposes
joeyschultz Oct 16, 2024
3601f92
Install and run pre-commit
joeyschultz Oct 16, 2024
735894d
Remove unused exception, fix CHANGELOG links, and other minor updates
joeyschultz Oct 21, 2024
8770da0
Reorganize some of the notebook functions
joeyschultz Oct 21, 2024
78dd9df
Modify assumption comments in get_variable_values for clarity
joeyschultz Oct 21, 2024
25cdc10
Add to varinfo config, re-enable MissingReprojectedDataError, modify …
joeyschultz Oct 23, 2024
b707bd2
Remove TEMPO_O3TOT_L2_example.ipynb and add it to JIRA ticket instead.
joeyschultz Oct 23, 2024
6678d5a
Simplify variable transposal, update effected typehints and unit tests
joeyschultz Oct 25, 2024
e5d4be1
Merge remote-tracking branch 'origin/main' into mhs/DAS-2216/quick-fixes
joeyschultz Oct 25, 2024
bde29b6
Add get_rows_per_scan utility and associated unit tests
joeyschultz Oct 28, 2024
cd54588
Apply coordinates MetadataOverride to geolocation group
joeyschultz Oct 28, 2024
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
25 changes: 23 additions & 2 deletions swath_projector/earthdata_varinfo_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,27 @@
"VNP10": "VIIRS",
"TEMPO_O3TOT_L2": "TEMPO"
},
"ExcludedScienceVariables": [
{
"Applicability": {
"Mission": "TEMPO",
"ShortNamePath": "TEMPO_O3TOT_L2"
},
"VariablePattern": [
"/support_data/a_priori_layer_o3",
"/support_data/cal_adjustment",
"/support_data/dNdR",
"/support_data/layer_efficiency",
"/support_data/lut_wavelength",
"/support_data/N_value",
"/support_data/N_value_residual",
"/support_data/ozone_sensitivity_ratio",
"/support_data/step_1_N_value_residual",
"/support_data/step_2_N_value_residual",
"/support_data/temp_sensitivity_ratio"
]
}
],
owenlittlejohns marked this conversation as resolved.
Show resolved Hide resolved
"MetadataOverrides": [
{
"Applicability": {
Expand All @@ -28,15 +49,15 @@
"Applicability": {
"Mission": "TEMPO",
"ShortNamePath": "TEMPO_O3TOT_L2",
"VariablePattern": "/product/.*|/support_data/.*"
"VariablePattern": "^/product/.*|^/support_data/.*"
},
"Attributes": [
{
"Name": "coordinates",
"Value": "/geolocation/latitude, /geolocation/longitude"
lyonthefrog marked this conversation as resolved.
Show resolved Hide resolved
}
],
"_Description": "TEMPO variables only have simple, single names for coordinates, but need full paths."
"_Description": "TEMPO_O3TOT_L2 variables only contain basenames for coordinates, which are found in sibling hierarchical groups. This rule fully qualifies the paths to these coordinates."
owenlittlejohns marked this conversation as resolved.
Show resolved Hide resolved
}
]
}
3 changes: 2 additions & 1 deletion swath_projector/nc_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from netCDF4 import Dataset, Variable
from varinfo import VarInfoFromNetCDF4

from swath_projector.exceptions import MissingReprojectedDataError
from swath_projector.utilities import get_variable_file_path, variable_in_dataset

# Values needed for history_json attribute
Expand Down Expand Up @@ -94,7 +95,7 @@ def create_output(

else:
logger.error(f'Cannot find "{dataset_file}".')
# QuickFix (DAS-2216) Ignore missing reprojections
raise MissingReprojectedDataError(variable_name)


def set_output_attributes(
Expand Down
3 changes: 2 additions & 1 deletion swath_projector/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def get_variable_values(
As the variable data are returned as a `numpy.ma.MaskedArray`, the will
return no data in the filled pixels. To ensure that the data are
correctly handled, the fill value is applied to masked pixels using the
`filled` method.
`filled` method. The variable values are transposed if the `along-track`
dimension size is less than the `across-track` dimension size.

"""
# TODO: Remove in favour of apply2D or process_subdimension.
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/test_nc_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import os
from datetime import datetime
from unittest import TestCase, skip
from unittest import TestCase
from unittest.mock import Mock, patch

from netCDF4 import Dataset
Expand Down Expand Up @@ -186,7 +186,6 @@ def test_same_data_type(self):
output_data_type = out_dataset[test_variable].datatype
self.assertEqual(input_data_type, output_data_type, 'Should be equal')

@skip("Test disabled for DAS-2216 quick fix that ignores missing reprojections")
def test_missing_file_raises_error(self):
"""If a science variable should be included in the output, but there
is no associated output file, an exception should be raised.
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,41 +366,41 @@ def test_make_array_two_dimensional(self):
class TestTransposeIfXdimLessThanYdim(TestCase):
owenlittlejohns marked this conversation as resolved.
Show resolved Hide resolved

def test_wider_than_tall(self):
# Test case where x dim < y dim and should transpose
"""Test case where x dim < y dim and should transpose."""
input_array = np.ma.array([[1, 2, 3], [4, 5, 6]])
expected_output = np.ma.array([[1, 4], [2, 5], [3, 6]])
result = transpose_if_xdim_less_than_ydim(input_array)
np.testing.assert_array_equal(result, expected_output)
self.assertEqual(result.shape, (3, 2))

def test_taller_than_wide(self):
# Test case where x < y and should not transpose.
"""Test case where x < y and should not transpose."""
input_array = np.ma.array([[1, 2], [3, 4], [5, 6]])
result = transpose_if_xdim_less_than_ydim(input_array)
np.testing.assert_array_equal(result, input_array)
self.assertEqual(result.shape, (3, 2))

def test_square_array(self):
# test where y dim == x dim and should not transpose.
"""Test case where y dim == x dim and should not transpose."""
input_array = np.ma.array([[1, 2], [3, 4]])
result = transpose_if_xdim_less_than_ydim(input_array)
np.testing.assert_array_equal(result, input_array)
self.assertEqual(result.shape, (2, 2))

def test_1d_array(self):
# Test case with a 1D array
"""Test case with a 1D array"""
input_array = np.ma.array([1, 2, 3])
with self.assertRaisesRegex(ValueError, 'variable must be 2 dimensional'):
owenlittlejohns marked this conversation as resolved.
Show resolved Hide resolved
transpose_if_xdim_less_than_ydim(input_array)

def test_3d_array(self):
# Test case with a 3D array
"""Test case with a 3D array"""
input_array = np.ma.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
with self.assertRaisesRegex(ValueError, 'variable must be 2 dimensional'):
owenlittlejohns marked this conversation as resolved.
Show resolved Hide resolved
transpose_if_xdim_less_than_ydim(input_array)

def test_masked_array(self):
# Test case with a masked array
"""Test case with a masked array"""
input_array = np.ma.array(
[[1, 2, 3], [4, 5, 6]], mask=[[True, False, False], [False, True, False]]
)
Expand Down
Loading