Skip to content

Commit

Permalink
Add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
awarde96 committed Sep 16, 2024
1 parent 11294a2 commit f527491
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
4 changes: 4 additions & 0 deletions covjsonkit/api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import logging

from conflator import Conflator

import covjsonkit.decoder.BoundingBox
Expand Down Expand Up @@ -42,9 +44,11 @@ def __init__(self, config=None):
# If no config check default locations
if config is None:
self.conf = Conflator(app_name="covjsonkit", model=CovjsonKitConfig).load()
logging.debug("Config loaded from file: %s", self.conf) # noqa: E501
# else initialise with provided config
else:
self.conf = CovjsonKitConfig.model_validate(config)
logging.debug("Config loaded from dictionary: %s", self.conf) # noqa: E501

def encode(self, type, domaintype):
if domaintype == "timeseries":
Expand Down
12 changes: 7 additions & 5 deletions covjsonkit/encoder/BoundingBox.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import logging

from .encoder import Encoder


Expand Down Expand Up @@ -93,6 +95,9 @@ def from_polytope(self, result):

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

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

self.add_reference(
{
"coordinates": ["x", "y", "z"],
Expand Down Expand Up @@ -129,10 +134,8 @@ def from_polytope(self, result):
levels = fields["levels"]
for para in fields["param"]:
self.add_parameter(para)
# for date in range_dict.keys():
# for level in range_dict[date].keys():
# levels.append(level)
# break

logging.debug("The parameters added were: %s", self.parameters) # noqa: E501

for date in coords.keys():
coord = coords[date]["composite"]
Expand All @@ -141,7 +144,6 @@ def from_polytope(self, result):
for cor in coord:
coords[date]["composite"].append([cor[0], cor[1], level])

print(combined_dict)
for date in combined_dict.keys():
for num in combined_dict[date].keys():
val_dict = {}
Expand Down
6 changes: 6 additions & 0 deletions covjsonkit/encoder/TimeSeries.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
from datetime import datetime, timedelta

import pandas as pd
Expand Down Expand Up @@ -114,6 +115,8 @@ def from_polytope(self, result):
for para in fields["param"]:
self.add_parameter(para)

logging.debug("The parameters added were: %s", self.parameters) # noqa: E501

for date in fields["dates"]:
coordinates[date] = {
"x": [coords[date]["composite"][0][0]],
Expand All @@ -135,6 +138,9 @@ def from_polytope(self, result):
break
break

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

for date in fields["dates"]:
for level in fields["levels"]:
for num in fields["number"]:
Expand Down
11 changes: 2 additions & 9 deletions covjsonkit/encoder/VerticalProfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ def from_xarray(self, dataset):
for num in dataset["number"].values:
self.add_coverage(
{
# "date": fc_time.values.astype("M8[ms]")
# .astype("O")
# .strftime("%m/%d/%Y"),
"number": num,
"type": "forecast",
"step": 0,
Expand All @@ -86,10 +83,6 @@ def from_xarray(self, dataset):

def from_polytope(self, result):
coords = {}
# coords['x'] = []
# coords['y'] = []
# coords['z'] = []
# coords['t'] = []
mars_metadata = {}
range_dict = {}
lat = 0
Expand Down Expand Up @@ -130,16 +123,16 @@ def from_polytope(self, result):
for date in range_dict.keys():
for num in range_dict[date].keys():
for param in range_dict[date][num].keys():
# self.coord_length = len(range_dict[date][param])
self.add_parameter(param)
break
break

logging.debug("The parameters added were: %s", self.parameters) # noqa: E501

for date in range_dict.keys():
for num in range_dict[date].keys():
mm = mars_metadata.copy()
mm["number"] = num
# mm["Forecast date"] = date
del mm["date"]
self.add_coverage(mm, coords[date], range_dict[date][num])

Expand Down

0 comments on commit f527491

Please sign in to comment.