Skip to content

Commit

Permalink
Remove remaining references to eccovjson
Browse files Browse the repository at this point in the history
  • Loading branch information
awarde96 committed May 23, 2024
1 parent 5f96fc8 commit 1ebc398
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 92 deletions.
2 changes: 1 addition & 1 deletion covjsonkit/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
}


class Eccovjson:
class Covjsonkit:
def __init__(self):
pass

Expand Down
1 change: 0 additions & 1 deletion covjsonkit/encoder/encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from covjson_pydantic.parameter import Parameter
from covjson_pydantic.reference_system import ReferenceSystemConnectionObject

# from eccovjson.CoverageCollection import CoverageCollection
from covjsonkit.param_db import get_param_from_db, get_unit_from_db


Expand Down
47 changes: 10 additions & 37 deletions tests/test_decoder_time_series.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# from earthkit import data

from covjsonkit.api import Eccovjson
from covjsonkit.api import Covjsonkit


class TestDecoder:
Expand Down Expand Up @@ -138,19 +138,19 @@ def setup_method(self, method):
def test_timeseries_type(self):
# decoder = TimeSeries.TimeSeries(self.covjson)
# assert decoder.type == "CoverageCollection"
decoder = Eccovjson().decode(self.covjson)
decoder = Covjsonkit().decode(self.covjson)
assert decoder.type == "CoverageCollection"

def test_timeseries_parameters(self):
decoder = Eccovjson().decode(self.covjson)
decoder = Covjsonkit().decode(self.covjson)
assert decoder.parameters == ["t", "p"]

def test_timeseries_referencing(self):
decoder = Eccovjson().decode(self.covjson)
decoder = Covjsonkit().decode(self.covjson)
assert decoder.get_referencing() == ["x", "y", "z"]

def test_timeseries_mars_metadata(self):
decoder = Eccovjson().decode(self.covjson)
decoder = Covjsonkit().decode(self.covjson)
metadata1 = {
"class": "od",
"stream": "oper",
Expand All @@ -170,7 +170,7 @@ def test_timeseries_mars_metadata(self):
assert decoder.mars_metadata == [metadata1, metadata2]

def test_timeseries_domains(self):
decoder = Eccovjson().decode(self.covjson)
decoder = Covjsonkit().decode(self.covjson)
domain1 = {
"type": "Domain",
"axes": {
Expand Down Expand Up @@ -205,7 +205,7 @@ def test_timeseries_domains(self):
assert decoder.domains[1] == domain2

def test_timeseries_ranges(self):
decoder = Eccovjson().decode(self.covjson)
decoder = Covjsonkit().decode(self.covjson)
range1 = {
"t": {
"type": "NdArray",
Expand Down Expand Up @@ -242,7 +242,7 @@ def test_timeseries_ranges(self):
assert decoder.ranges[1] == range2

def test_timeseries_values(self):
decoder = Eccovjson().decode(self.covjson)
decoder = Covjsonkit().decode(self.covjson)
values = {
"t": [
[264.93115234375, 263.83115234375, 265.12313132266],
Expand All @@ -256,7 +256,7 @@ def test_timeseries_values(self):
assert decoder.get_values() == values

def test_timeseries_coordinates(self):
decoder = Eccovjson().decode(self.covjson)
decoder = Covjsonkit().decode(self.covjson)
coordinates = {
"t": [
[
Expand Down Expand Up @@ -287,7 +287,7 @@ def test_timeseries_coordinates(self):
assert decoder.get_coordinates() == coordinates

def test_timeseries_to_xarray(self):
# decoder = Eccovjson().decode(self.covjson)
# decoder = Covjsonkit().decode(self.covjson)
# ds = decoder.to_xarray()
# print(ds)
# print(ds["Temperature"])
Expand All @@ -298,30 +298,3 @@ def test_timeseries_to_xarray(self):
# print(type(ekds))
# print(ekds.ls())
pass


"""
[<xarray.DataArray 't' (x: 1, y: 1, z: 1, t: 6)>
array([[[[264.93115234, 263.83115234, 265.12313132, 263.83115234,
265.12313132, 264.93115234]]]])
Coordinates:
* x (x) int64 3
* y (y) int64 7
* z (z) int64 1
* t (t) datetime64[ns] 2017-01-01 ... 2017-01-02T12:00:00
Attributes:
type: Parameter
units: K
long_name: Temperature, <xarray.DataArray 'p' (x: 1, y: 1, z: 1, t: 6)>
array([[[[ 9.93115234, 7.83115234, 14.12313132, 13.83115234,
14.12313132, 7.93115234]]]])
Coordinates:
* x (x) int64 3
* y (y) int64 7
* z (z) int64 1
* t (t) datetime64[ns] 2017-01-01 ... 2017-01-02T12:00:00
Attributes:
type: Parameter
units: pa
long_name: Pressure]
"""
22 changes: 11 additions & 11 deletions tests/test_decoder_vertical_profile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from covjsonkit.api import Eccovjson
from covjsonkit.api import Covjsonkit


class TestDecoder:
Expand Down Expand Up @@ -113,19 +113,19 @@ def setup_method(self, method):
}

def test_verticalprofile_type(self):
decoder = Eccovjson().decode(self.covjson)
decoder = Covjsonkit().decode(self.covjson)
assert decoder.type == "CoverageCollection"

def test_verticalprofile_parameters(self):
decoder = Eccovjson().decode(self.covjson)
decoder = Covjsonkit().decode(self.covjson)
assert decoder.parameters == ["t", "p"]

def test_verticalprofile_referencing(self):
decoder = Eccovjson().decode(self.covjson)
decoder = Covjsonkit().decode(self.covjson)
assert decoder.get_referencing() == ["x", "y", "z"]

def test_verticalprofile_mars_metadata(self):
decoder = Eccovjson().decode(self.covjson)
decoder = Covjsonkit().decode(self.covjson)
metadata1 = {
"class": "ea",
"date": "2017-01-01 12:00:00",
Expand All @@ -146,7 +146,7 @@ def test_verticalprofile_mars_metadata(self):
assert decoder.mars_metadata[1] == metadata2

def test_verticalprofile_domains(self):
decoder = Eccovjson().decode(self.covjson)
decoder = Covjsonkit().decode(self.covjson)
domain1 = {
"type": "Domain",
"domainType": "VerticalProfile",
Expand All @@ -171,7 +171,7 @@ def test_verticalprofile_domains(self):
assert decoder.domains[1] == domain2

def test_verticalprofile_ranges(self):
decoder = Eccovjson().decode(self.covjson)
decoder = Covjsonkit().decode(self.covjson)
range1 = {
"t": {
"type": "NdArray",
Expand Down Expand Up @@ -208,7 +208,7 @@ def test_verticalprofile_ranges(self):
assert decoder.ranges[1] == range2

def test_verticalprofile_coordinates(self):
decoder = Eccovjson().decode(self.covjson)
decoder = Covjsonkit().decode(self.covjson)
coordinates = {
"t": [
[
Expand All @@ -234,16 +234,16 @@ def test_verticalprofile_coordinates(self):
assert decoder.get_coordinates() == coordinates

def test_verticalprofile_values(self):
decoder = Eccovjson().decode(self.covjson)
decoder = Covjsonkit().decode(self.covjson)
values = {
"t": [[57517.77734375, 14814.95703125], [57452.35546875, 14822.98046875]],
"p": [[16452.35546875, 44122.98046875], [56452.35546875, 14122.98046875]],
}
assert decoder.get_values() == values

# def test_verticalprofile_to_xarray(self):
# decoder = Eccovjson().decode(self.covjson)
# decoder = Covjsonkit().decode(self.covjson)
# dataset = decoder.to_xarray()
# encoder = eccovjson.encoder.VerticalProfile.VerticalProfile("CoverageCollection", "VerticalProfile")
# encoder = Covjsonkit.encoder.VerticalProfile.VerticalProfile("CoverageCollection", "VerticalProfile")
# cov = encoder.from_xarray(dataset)
# print(cov)
14 changes: 7 additions & 7 deletions tests/test_encoder_bounding_box.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from covjson_pydantic.coverage import CoverageCollection
from covjson_pydantic.domain import DomainType

from covjsonkit.api import Eccovjson
from covjsonkit.api import Covjsonkit


def get_timestamps(start_dt, end_dt, delta):
Expand Down Expand Up @@ -139,27 +139,27 @@ def setup_method(self, method):
}

def test_CoverageCollection(self):
encoder_obj = Eccovjson().encode("CoverageCollection", "BoundingBox")
encoder_obj = Covjsonkit().encode("CoverageCollection", "BoundingBox")
assert encoder_obj.type == "CoverageCollection"

def test_standard_Coverage(self):
encoder_obj = Eccovjson().encode("CoverageCollection", "BoundingBox")
encoder_obj = Covjsonkit().encode("CoverageCollection", "BoundingBox")
covjson = CoverageCollection(
type="CoverageCollection", coverages=[], domainType=DomainType.multi_point, parameters={}, referencing=[]
)

assert encoder_obj.get_json() == covjson.model_dump_json(exclude_none=True, indent=4)

def test_add_parameter(self):
encoder_obj = Eccovjson().encode("CoverageCollection", "BoundingBox")
encoder_obj = Covjsonkit().encode("CoverageCollection", "BoundingBox")
encoder_obj.add_parameter(167)
encoder_obj.add_parameter(166)

json_string = encoder_obj.pydantic_coverage.model_dump_json(exclude_none=True, indent=4)
assert CoverageCollection.model_validate_json(json_string)

def test_add_reference(self):
encoder_obj = Eccovjson().encode("CoverageCollection", "BoundingBox")
encoder_obj = Covjsonkit().encode("CoverageCollection", "BoundingBox")
encoder_obj.add_reference(
{
"coordinates": ["x", "y", "z"],
Expand All @@ -175,7 +175,7 @@ def test_add_reference(self):
assert CoverageCollection.model_validate_json(json_string)

def test_add_coverage(self):
encoder = Eccovjson().encode("CoverageCollection", "BoundingBox")
encoder = Covjsonkit().encode("CoverageCollection", "BoundingBox")
encoder.add_parameter(167)
encoder.add_reference(
{
Expand Down Expand Up @@ -213,7 +213,7 @@ def test_add_coverage(self):
def test_from_xarray(self):
ds = xr.open_dataset("new_timeseries.nc")
encoder = Eccovjson().encode("CoverageCollection", "PointSeries")
encoder = Covjsonkit().encode("CoverageCollection", "PointSeries")
encoder.from_xarray(ds)
"""
14 changes: 7 additions & 7 deletions tests/test_encoder_frame.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from covjson_pydantic.coverage import CoverageCollection
from covjson_pydantic.domain import DomainType

from covjsonkit.api import Eccovjson
from covjsonkit.api import Covjsonkit


def get_timestamps(start_dt, end_dt, delta):
Expand Down Expand Up @@ -139,27 +139,27 @@ def setup_method(self, method):
}

def test_CoverageCollection(self):
encoder_obj = Eccovjson().encode("CoverageCollection", "Frame")
encoder_obj = Covjsonkit().encode("CoverageCollection", "Frame")
assert encoder_obj.type == "CoverageCollection"

def test_standard_Coverage(self):
encoder_obj = Eccovjson().encode("CoverageCollection", "Frame")
encoder_obj = Covjsonkit().encode("CoverageCollection", "Frame")
covjson = CoverageCollection(
type="CoverageCollection", coverages=[], domainType=DomainType.multi_point, parameters={}, referencing=[]
)

assert encoder_obj.get_json() == covjson.model_dump_json(exclude_none=True, indent=4)

def test_add_parameter(self):
encoder_obj = Eccovjson().encode("CoverageCollection", "Frame")
encoder_obj = Covjsonkit().encode("CoverageCollection", "Frame")
encoder_obj.add_parameter(167)
encoder_obj.add_parameter(166)

json_string = encoder_obj.pydantic_coverage.model_dump_json(exclude_none=True, indent=4)
assert CoverageCollection.model_validate_json(json_string)

def test_add_reference(self):
encoder_obj = Eccovjson().encode("CoverageCollection", "Frame")
encoder_obj = Covjsonkit().encode("CoverageCollection", "Frame")
encoder_obj.add_reference(
{
"coordinates": ["x", "y", "z"],
Expand All @@ -175,7 +175,7 @@ def test_add_reference(self):
assert CoverageCollection.model_validate_json(json_string)

def test_add_coverage(self):
encoder = Eccovjson().encode("CoverageCollection", "Frame")
encoder = Covjsonkit().encode("CoverageCollection", "Frame")
encoder.add_parameter(167)
encoder.add_reference(
{
Expand Down Expand Up @@ -213,7 +213,7 @@ def test_add_coverage(self):
def test_from_xarray(self):
ds = xr.open_dataset("new_timeseries.nc")
encoder = Eccovjson().encode("CoverageCollection", "PointSeries")
encoder = Covjsonkit().encode("CoverageCollection", "PointSeries")
encoder.from_xarray(ds)
"""
14 changes: 7 additions & 7 deletions tests/test_encoder_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from covjson_pydantic.coverage import CoverageCollection
from covjson_pydantic.domain import DomainType

from covjsonkit.api import Eccovjson
from covjsonkit.api import Covjsonkit


def get_timestamps(start_dt, end_dt, delta):
Expand Down Expand Up @@ -141,12 +141,12 @@ def setup_method(self, method):

@pytest.mark.skip(reason="Trajecotry not implemented in covjson-pydantic yet")
def test_CoverageCollection(self):
encoder_obj = Eccovjson().encode("CoverageCollection", "Path")
encoder_obj = Covjsonkit().encode("CoverageCollection", "Path")
assert encoder_obj.type == "CoverageCollection"

@pytest.mark.skip(reason="Trajecotry not implemented in covjson-pydantic yet")
def test_standard_Coverage(self):
encoder_obj = Eccovjson().encode("CoverageCollection", "Path")
encoder_obj = Covjsonkit().encode("CoverageCollection", "Path")
covjson = CoverageCollection(
type="CoverageCollection", coverages=[], domainType=DomainType.trajectory, parameters={}, referencing=[]
)
Expand All @@ -155,7 +155,7 @@ def test_standard_Coverage(self):

@pytest.mark.skip(reason="Trajecotry not implemented in covjson-pydantic yet")
def test_add_parameter(self):
encoder_obj = Eccovjson().encode("CoverageCollection", "Path")
encoder_obj = Covjsonkit().encode("CoverageCollection", "Path")
encoder_obj.add_parameter(167)
encoder_obj.add_parameter(166)

Expand All @@ -164,7 +164,7 @@ def test_add_parameter(self):

@pytest.mark.skip(reason="Trajecotry not implemented in covjson-pydantic yet")
def test_add_reference(self):
encoder_obj = Eccovjson().encode("CoverageCollection", "Path")
encoder_obj = Covjsonkit().encode("CoverageCollection", "Path")
encoder_obj.add_reference(
{
"coordinates": ["x", "y", "z"],
Expand All @@ -181,7 +181,7 @@ def test_add_reference(self):

@pytest.mark.skip(reason="Trajecotry not implemented in covjson-pydantic yet")
def test_add_coverage(self):
encoder = Eccovjson().encode("CoverageCollection", "Path")
encoder = Covjsonkit().encode("CoverageCollection", "Path")
encoder.add_parameter(167)
encoder.add_reference({"coordinates": ["t"], "system": {"type": "TemporalRS", "calendar": "Gregorian"}})
encoder.add_reference(
Expand Down Expand Up @@ -223,7 +223,7 @@ def test_add_coverage(self):
def test_from_xarray(self):
ds = xr.open_dataset("new_timeseries.nc")
encoder = Eccovjson().encode("CoverageCollection", "PointSeries")
encoder = Covjsonkit().encode("CoverageCollection", "PointSeries")
encoder.from_xarray(ds)
"""
Loading

0 comments on commit 1ebc398

Please sign in to comment.