Skip to content

Commit

Permalink
wip cds
Browse files Browse the repository at this point in the history
  • Loading branch information
floriscalkoen committed Dec 2, 2024
1 parent ec2e03b commit 21b5dfc
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 25 deletions.
1 change: 1 addition & 0 deletions specification/schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@
"AIModel",
"Cassie",
"CoastSat",
"FieldSurvey",
"ManualDigitization",
"ShorelineMonitor",
"Thresholding"
Expand Down
20 changes: 4 additions & 16 deletions src/coastpy/schema/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
from .schema_hooks import custom_schema_hook, decode_custom, encode_custom
from .type_enums import (
CoastalType,
HasDefense,
IsBuiltEnvironment,
LandformType,
ShoreType,
)
from .types import (
BaseModel,
SatelliteDerivedShorelinePosition,
SatelliteDerivedWaterLine,
Transect,
TypologyInferenceSample,
TypologyTestSample,
Expand All @@ -17,17 +11,11 @@

__all__ = [
"BaseModel",
"CoastalType",
"HasDefense",
"IsBuiltEnvironment",
"LandformType",
"ShoreType",
"SatelliteDerivedShorelinePosition",
"SatelliteDerivedWaterLine",
"Transect",
"TypologyInferenceSample",
"TypologyTestSample",
"TypologyTrainSample",
"custom_schema_hook",
"decode_custom",
"encode_custom",
"read_records_to_pandas",
]
19 changes: 10 additions & 9 deletions src/coastpy/schema/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ def example(cls) -> "TypologyInferenceSample":
return cls(**_EXAMPLE_VALUES)


class SatelliteDerivedWaterLine(msgspec.Struct, tag="sdw"):
class SatelliteDerivedWaterLine(BaseModel, tag="sdw"):
id: Annotated[str, msgspec.Meta(description="Unique identifier for the waterline")]
geometry: Annotated[
LineString,
Expand Down Expand Up @@ -763,14 +763,7 @@ def example(cls):
)


import datetime
from typing import Annotated

import msgspec
from shapely.geometry import LineString


class SatelliteDerivedShorelinePosition(msgspec.Struct, tag="sdsp"):
class SatelliteDerivedShorelinePosition(BaseModel, tag="sdsp"):
sdw_id: Annotated[
str,
msgspec.Meta(
Expand All @@ -790,6 +783,12 @@ class SatelliteDerivedShorelinePosition(msgspec.Struct, tag="sdsp"):
description="Timestamp for when the shoreline position was determined"
),
]
chainage: Annotated[
float,
msgspec.Meta(
description="Distance along the transect from the start point to the shoreline position"
),
]
waterline_type: WaterLineType
tidal_height: Annotated[
float | None,
Expand Down Expand Up @@ -827,6 +826,7 @@ def example(cls):
transect_id="transect_123", # Reference to an example transect
geometry=Point(4.277131, 52.112953),
determination_datetime=datetime.datetime(2024, 1, 15, 12, 0),
chainage=123.45,
waterline_type="instantaneous",
tidal_height=2.5,
slope=0.15,
Expand All @@ -839,4 +839,5 @@ def example(cls):
| TypologyTestSample
| TypologyInferenceSample
| SatelliteDerivedWaterLine
| SatelliteDerivedShorelinePosition
)
146 changes: 146 additions & 0 deletions tutorials/coastal_data_specification.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": [
"from coastpy.schema import (\n",
" SatelliteDerivedShorelinePosition,\n",
" SatelliteDerivedWaterLine,\n",
" Transect,\n",
" TypologyTestSample,\n",
" TypologyTrainSample,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"transect = Transect.example()\n",
"transect"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"transect.to_frame()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"typology_train_sample = TypologyTrainSample.example()\n",
"typology_train_sample"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"typology_train_sample.to_frame()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"typology_test_sample = TypologyTestSample.example()\n",
"typology_test_sample"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"typology_test_sample.to_frame()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sdw = SatelliteDerivedWaterLine.example()\n",
"sdw"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sdw.to_frame()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sdsp = SatelliteDerivedShorelinePosition.example()\n",
"sdsp"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sdsp.to_frame()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python [conda env:coastal-full] *",
"language": "python",
"name": "conda-env-coastal-full-py"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.7"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

0 comments on commit 21b5dfc

Please sign in to comment.