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
133 changes: 63 additions & 70 deletions geometric_features/features_and_tags.json
Original file line number Diff line number Diff line change
Expand Up @@ -812,114 +812,111 @@
"eastCentralGreenland1": [
"eastCentralGreenland"
],
"eastCentralGreenland1_oceanExtended": [
"eastCentralGreenland"
],
"eastCentralGreenland2": [
"eastCentralGreenland"
],
"eastCentralGreenland2_oceanExtended": [
"eastCentralGreenland"
],
"eastCentralGreenland3": [
"eastCentralGreenland"
],
"eastCentralGreenland3_oceanExtended": [
"eastCentralGreenland"
],
"northEastGreenland1": [
"northEastGreenland"
],
"northEastGreenland1_oceanExtended": [
"northEastGreenland"
],
"northEastGreenland2": [
"northEastGreenland"
],
"northEastGreenland2_oceanExtended": [
"northEastGreenland"
],
"northGreenland1": [
"northGreenland"
],
"northGreenland1_oceanExtended": [
"northGreenland"
],
"northGreenland2": [
"northGreenland"
],
"northGreenland2_oceanExtended": [
"northGreenland"
],
"northGreenland3": [
"northGreenland"
],
"northGreenland3_oceanExtended": [
"northGreenland"
],
"northGreenland4": [
"northGreenland"
],
"northWestGreenland1": [
"northWestGreenland"
],
"northWestGreenland1_oceanExtended": [
"northWestGreenland"
],
"northWestGreenland2": [
"northWestGreenland"
],
"northWestGreenland2_oceanExtended": [
"northWestGreenland"
],
"southEastGreenland1": [
"southEastGreenland"
],
"southEastGreenland2": [
"southEastGreenland1_oceanExtended": [
"southEastGreenland"
],
"southEastGreenland3": [
"southEastGreenland2": [
"southEastGreenland"
],
"southGreenland1": [
"southGreenland"
],
"southWestGreenland1": [
"southWestGreenland"
],
"southWestGreenland2": [
"southWestGreenland"
],
"westCentralGreenland1": [
"westCentralGreenland"
],
"westCentralGreenland2": [
"westCentralGreenland"
],
"eastCentralGreenland1_oceanExtended": [
"eastCentralGreenland"
],
"eastCentralGreenland2_oceanExtended": [
"eastCentralGreenland"
],
"eastCentralGreenland3_oceanExtended": [
"eastCentralGreenland"
],
"northEastGreenland1_oceanExtended": [
"northEastGreenland"
],
"northEastGreenland2_oceanExtended": [
"northEastGreenland"
],
"northGreenland1_oceanExtended": [
"northGreenland"
],
"northGreenland2_oceanExtended": [
"northGreenland"
],
"northGreenland3_oceanExtended": [
"northGreenland"
],
"northGreenland4_oceanExtended": [
"northGreenland"
],
"northWestGreenland1_oceanExtended": [
"northWestGreenland"
],
"northWestGreenland2_oceanExtended": [
"northWestGreenland"
],
"southEastGreenland1_oceanExtended": [
"southEastGreenland2_oceanExtended": [
"southEastGreenland"
],
"southEastGreenland2_oceanExtended": [
"southEastGreenland3": [
"southEastGreenland"
],
"southEastGreenland3_oceanExtended": [
"southEastGreenland"
],
"southGreenland1": [
"southGreenland"
],
"southGreenland1_oceanExtended": [
"southGreenland"
],
"southWestGreenland1": [
"southWestGreenland"
],
"southWestGreenland1_oceanExtended": [
"southWestGreenland"
],
"southWestGreenland2": [
"southWestGreenland"
],
"southWestGreenland2_oceanExtended": [
"southWestGreenland"
],
"westCentralGreenland1": [
"westCentralGreenland"
],
"westCentralGreenland1_oceanExtended": [
"westCentralGreenland"
],
"westCentralGreenland2": [
"westCentralGreenland"
],
"westCentralGreenland2_oceanExtended": [
"westCentralGreenland"
]
Expand Down Expand Up @@ -1921,58 +1918,54 @@
},
"seaice": {
"region": {
"April Historical Median Sea Ice Extent":[
"April Historical Median Sea Ice Extent": [
"QGreenland",
"Historical_Sea_Ice_Extent"
],
"August Historical Median Sea Ice Extent":[
"August Historical Median Sea Ice Extent": [
"QGreenland",
"Historical_Sea_Ice_Extent"
],
"December Historical Median Sea Ice Extent":[
"QGreenland",
"Historical_Sea_Ice_Extent"
],
"February Historical Median Sea Ice Extent":[
],
"December Historical Median Sea Ice Extent": [
"QGreenland",
"Historical_Sea_Ice_Extent"
],
"January Historical Median Sea Ice Extent":[
"February Historical Median Sea Ice Extent": [
"QGreenland",
"Historical_Sea_Ice_Extent"
],
"July Historical Median Sea Ice Extent":[
"January Historical Median Sea Ice Extent": [
"QGreenland",
"Historical_Sea_Ice_Extent"
],
"June Historical Median Sea Ice Extent":[
"July Historical Median Sea Ice Extent": [
"QGreenland",
"Historical_Sea_Ice_Extent"
],
"March Historical Median Sea Ice Extent":[
"June Historical Median Sea Ice Extent": [
"QGreenland",
"Historical_Sea_Ice_Extent"
],
"May Historical Median Sea Ice Extent":[
"March Historical Median Sea Ice Extent": [
"QGreenland",
"Historical_Sea_Ice_Extent"
],
"November Historical Median Sea Ice Extent":[
"May Historical Median Sea Ice Extent": [
"QGreenland",
"Historical_Sea_Ice_Extent"
],
"March Historical Median Sea Ice Extent":[
"November Historical Median Sea Ice Extent": [
"QGreenland",
"Historical_Sea_Ice_Extent"
],
"October Historical Median Sea Ice Extent":[
"October Historical Median Sea Ice Extent": [
"QGreenland",
"Historical_Sea_Ice_Extent"
],
"September Historical Median Sea Ice Extent":[
"September Historical Median Sea Ice Extent": [
"QGreenland",
"Historical_Sea_Ice_Extent"
]
}
}
}
}
40 changes: 40 additions & 0 deletions geometric_features/test/test_features_and_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import difflib
import os

import pytest

from geometric_features.test import TestCase, loaddatadir
from geometric_features.utils import write_feature_names_and_tags


@pytest.mark.usefixtures('loaddatadir')
class TestFeaturesAndTags(TestCase):

def test_features_and_tags(self):
if 'GEOMETRIC_DATA_DIR' in os.environ:
cache_location = os.environ['GEOMETRIC_DATA_DIR']
else:
cache_location = './geometric_data'
write_feature_names_and_tags(cacheLocation=cache_location, quiet=True)
assert os.path.exists('features_and_tags.json')

filename1 = 'geometric_features/features_and_tags.json'
filename2 = 'features_and_tags.json'
with open(filename1, 'r') as f:
lines1 = f.readlines()

with open(filename2, 'r') as f:
lines2 = f.readlines()

diff = difflib.unified_diff(lines1, lines2, fromfile=filename1,
tofile=filename2)

count = 0
for line in diff:
print(line)
count + 1

if count != 0:
raise ValueError(
'Unexpected differences in geometric_features/features_and_tags.json '
'compared with the results of geometric_features.utils.write_feature_names_and_tags()')
8 changes: 6 additions & 2 deletions geometric_features/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import datetime


def write_feature_names_and_tags(cacheLocation='./geometry_data'):
def write_feature_names_and_tags(cacheLocation='./geometry_data', quiet=False):
"""
Make a json file with all the available features and tags by component
and object type, used to update the file when new geometric features are
Expand All @@ -20,6 +20,9 @@ def write_feature_names_and_tags(cacheLocation='./geometry_data'):
----------
cacheLocation : str, optional
The location of the geometric features cache

quiet : bool, optional
Whether to suppress printing of feature filenames
"""
# Authors
# -------
Expand All @@ -29,7 +32,8 @@ def write_feature_names_and_tags(cacheLocation='./geometry_data'):

allFeaturesAndTags = OrderedDict()
for fileName in fileNames:
print(fileName)
if not quiet:
print(fileName)
with open(fileName) as f:
features = json.load(f)['features']
feature = features[0]
Expand Down
Loading