Skip to content

Commit

Permalink
Merge branch 'main' into default-dims
Browse files Browse the repository at this point in the history
  • Loading branch information
ecomodeller authored Mar 13, 2024
2 parents 7b4dedd + 6127a04 commit 3dd0a94
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions mikeio/dfs/_dfs0.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from functools import cached_property
from pathlib import Path
from datetime import datetime, timedelta
from typing import Sequence
from typing import Any, Sequence

import numpy as np
import pandas as pd
from mikecore.DfsFactory import DfsBuilder, DfsFactory
from mikecore.DfsFile import DataValueType, DfsSimpleType, StatType, TimeAxisType
from mikecore.DfsFile import DfsSimpleType, StatType, TimeAxisType
from mikecore.DfsFileFactory import DfsFileFactory
from mikecore.eum import eumQuantity

Expand Down Expand Up @@ -55,13 +55,7 @@ def _write_dfs0(
newitem = builder.CreateDynamicItemBuilder()
quantity = eumQuantity.Create(da.type, da.unit)
newitem.Set(da.name, quantity, dfs_dtype)

# TODO set default on DataArray
if da.item.data_value_type is not None:
newitem.SetValueType(da.item.data_value_type)
else:
newitem.SetValueType(DataValueType.Instantaneous)

newitem.SetValueType(da.item.data_value_type)
newitem.SetAxis(factory.CreateAxisEqD0())
builder.AddDynamicItem(newitem.GetDynamicItemInfo())

Expand Down Expand Up @@ -141,7 +135,7 @@ def read(
self,
items: str | int | Sequence[str | int] | None = None,
time: int | str | slice | None = None,
keepdims: bool = False,
**kwargs: Any,
) -> Dataset:
"""
Read data from a dfs0 file.
Expand Down Expand Up @@ -305,7 +299,7 @@ def from_dataframe(
unit: EUMUnit, optional
Same unit for all items
items: list[ItemInfo]
Different types, units for each items, similar to `create`
Different types, units for each items
"""
return dataframe_to_dfs0(df, filename, itemtype, unit, items)

Expand Down

0 comments on commit 3dd0a94

Please sign in to comment.