Skip to content
Draft
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
7 changes: 0 additions & 7 deletions covjsonkit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +0,0 @@
import covjsonkit.api
import covjsonkit.decoder.TimeSeries
import covjsonkit.decoder.VerticalProfile
import covjsonkit.encoder.TimeSeries
import covjsonkit.encoder.VerticalProfile

from .version import __version__
3 changes: 2 additions & 1 deletion covjsonkit/encoder/BoundingBox.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ def from_polytope(self, result):
fields["levels"] = [0]

self.walk_tree(result, fields, coords, mars_metadata, range_dict)

if "hdate" in mars_metadata:
fields["dates"].remove(mars_metadata["Forecast date"] + "Z")
logging.debug("The values returned from walking tree: %s", range_dict) # noqa: E501
logging.debug("The coordinates returned from walking tree: %s", coords) # noqa: E501

Expand Down
2 changes: 2 additions & 0 deletions covjsonkit/encoder/Circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ def from_polytope(self, result):

self.walk_tree(result, fields, coords, mars_metadata, range_dict)

if "hdate" in mars_metadata:
fields["dates"].remove(mars_metadata["Forecast date"] + "Z")
logging.debug("The values returned from walking tree: %s", range_dict) # noqa: E501
logging.debug("The coordinates returned from walking tree: %s", coords) # noqa: E501

Expand Down
2 changes: 2 additions & 0 deletions covjsonkit/encoder/Frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ def from_polytope(self, result):

self.walk_tree(result, fields, coords, mars_metadata, range_dict)

if "hdate" in mars_metadata:
fields["dates"].remove(mars_metadata["Forecast date"] + "Z")
logging.debug("The values returned from walking tree: %s", range_dict) # noqa: E501
logging.debug("The coordinates returned from walking tree: %s", coords) # noqa: E501

Expand Down
2 changes: 2 additions & 0 deletions covjsonkit/encoder/Grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ def from_polytope(self, result):

self.walk_tree(result, fields, coords, mars_metadata, range_dict)

if "hdate" in mars_metadata:
fields["dates"].remove(mars_metadata["Forecast date"] + "Z")
logging.debug("The values returned from walking tree: %s", range_dict) # noqa: E501
logging.debug("The coordinates returned from walking tree: %s", coords) # noqa: E501

Expand Down
2 changes: 2 additions & 0 deletions covjsonkit/encoder/Path.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ def from_polytope(self, result):

self.walk_tree(result, fields, coords, mars_metadata, range_dict)

if "hdate" in mars_metadata:
fields["dates"].remove(mars_metadata["Forecast date"] + "Z")
if len(fields["l"]) == 0:
fields["l"] = [0]

Expand Down
3 changes: 3 additions & 0 deletions covjsonkit/encoder/Position.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ def from_polytope(self, result):
logging.debug("Tree walking ends at: %s", end) # noqa: E501
logging.debug("Tree walking takes: %s", delta) # noqa: E501

if "hdate" in mars_metadata:
fields["dates"].remove(mars_metadata["Forecast date"] + "Z")

start = time.time()
logging.debug("Coords creation: %s", start) # noqa: E501

Expand Down
3 changes: 3 additions & 0 deletions covjsonkit/encoder/Shapefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ def from_polytope(self, result):

self.walk_tree(result, fields, coords, mars_metadata, range_dict)

if "hdate" in mars_metadata:
fields["dates"].remove(mars_metadata["Forecast date"] + "Z")

logging.debug("The values returned from walking tree: %s", range_dict) # noqa: E501
logging.debug("The coordinates returned from walking tree: %s", coords) # noqa: E501

Expand Down
6 changes: 6 additions & 0 deletions covjsonkit/encoder/TimeSeries.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ def from_polytope(self, result):
start = time.time()
logging.debug("Tree walking starts at: %s", start) # noqa: E501
self.walk_tree(result, fields, coords, mars_metadata, range_dict)
print("coords: ", coords)
print("fields: ", fields)
print("mars_metadata: ", mars_metadata)
print("range_dict: ", range_dict)
if "hdate" in mars_metadata:
fields["dates"].remove(mars_metadata["Forecast date"] + "Z")
end = time.time()
delta = end - start
logging.debug("Tree walking ends at: %s", end) # noqa: E501
Expand Down
3 changes: 3 additions & 0 deletions covjsonkit/encoder/VerticalProfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ def from_polytope(self, result):
logging.debug("Tree walking ends at: %s", end) # noqa: E501
logging.debug("Tree walking takes: %s", delta) # noqa: E501

if "hdate" in mars_metadata:
fields["dates"].remove(mars_metadata["Forecast date"] + "Z")

start = time.time()
logging.debug("Coords creation: %s", start) # noqa: E501

Expand Down
9 changes: 9 additions & 0 deletions covjsonkit/encoder/encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ def handle_specific_axes(child):
coords[date]["composite"] = []
coords[date]["t"] = [date]
return dates
if child.axis.name == "hdate":
hdates = [f"{hdate}Z" for hdate in child.values]
for hdate in hdates:
coords[hdate] = {}
coords[hdate]["composite"] = []
coords[hdate]["t"] = [hdate]
return hdates
if child.axis.name == "number":
return child.values
if child.axis.name == "step":
Expand Down Expand Up @@ -202,6 +209,8 @@ def append_composite_coords(dates, tree_values, lat, coords):
fields["l"].extend(result)
elif child.axis.name == "param":
fields["param"] = result
elif child.axis.name in "hdate":
fields["dates"].extend(result)
elif child.axis.name in ["date", "time"]:
fields["dates"].extend(result)
elif child.axis.name == "number":
Expand Down
Loading