From 373455438bffe2ce95a0e1c6915935100d28b120 Mon Sep 17 00:00:00 2001 From: ajmuelle <114172102+ajmuelle@users.noreply.github.com> Date: Fri, 21 Jun 2024 09:53:45 -0400 Subject: [PATCH 1/8] TA3 Schema Integration and Metadata Parsing (#36) * Adds baseline implementation of schemas for TA3 integration * Updates the schema to include column information from shared spreadsheet * WIP implementation of schema for raw data sources * WIP scraping script for CMA raster data * First cut at extracting schema items from sciencebase * Adds .tif if not already present; shp files now supported * Cogifies tiffs now; import section cleanup * Adds options to cog generator * Fixes syntax errors in ta3_model.py * Cleans up import formatting more rigorously this time * Removes ta3 schema population script from this repo * Reformats ta3_input.py and ta3_model.py * Updates naming conventions in MTRI-defined schemas * Fixes formatting * Performs final renames that slipped under the radar * Update README with new ERD * Update docs to include prospectivity input and models * Reformats docs.py --------- Co-authored-by: Erick Vega --- README.md | 955 +++++++++++++++++----------- cdr_schemas/prospectivity_input.py | 99 +++ cdr_schemas/prospectivity_models.py | 113 ++++ dev/docs.py | 4 + 4 files changed, 810 insertions(+), 361 deletions(-) create mode 100644 cdr_schemas/prospectivity_input.py create mode 100644 cdr_schemas/prospectivity_models.py diff --git a/README.md b/README.md index 6a85117..d45a1f6 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,8 @@ poetry run docs [Mineral](#Mineral)
[Point Feature](#Point-Feature)
[Polygon Feature](#Polygon-Feature)
+ [Prospectivity Input](#Prospectivity-Input)
+ [Prospectivity Models](#Prospectivity-Models)
@@ -66,15 +68,24 @@ poetry run docs ```mermaid classDiagram + class GeomType { + <> + Point: str = 'Point' + LineString: str = 'LineString' + Polygon: str = 'Polygon' + } + class Area_Extraction { type: GeomType = GeomType.Polygon - coordinates: list[list[list[Union[float, int]]]] - bbox: list[Union[float, int]] = list + coordinates: list[list[list[float | int]]] + bbox: list[float | int] = list category: AreaType text: str = '' + reference_id: str = '' + validated: bool = False model: str model_version: str - confidence: Union[float, int, NoneType] = None + confidence: float | int | None = None } class AreaType { @@ -90,15 +101,8 @@ classDiagram Correlation_Diagram: str = 'correlation_diagram' } - class GeomType { - <> - Point: str = 'Point' - LineString: str = 'LineString' - Polygon: str = 'Polygon' - } - - Area_Extraction ..> AreaType Area_Extraction ..> GeomType + Area_Extraction ..> AreaType ``` @@ -113,39 +117,32 @@ classDiagram ```mermaid classDiagram - class GroundControlPoint { - gcp_id: str - map_geom: Geom_Point - px_geom: Pixel_Point - confidence: Union[float, int, NoneType] = None - model: str - model_version: str - crs: str - } - - class Area_Extraction { - type: GeomType = GeomType.Polygon - coordinates: list[list[list[Union[float, int]]]] - bbox: list[Union[float, int]] = list - category: AreaType - text: str = '' - model: str - model_version: str - confidence: Union[float, int, NoneType] = None + class GeoreferenceResults { + cog_id: str + georeference_results: list[GeoreferenceResult] = list + gcps: list[GroundControlPoint] = list + system: str + system_version: str } - class ProjectionResult { - crs: str - gcp_ids: list[str] - file_name: str + class Geom_Point { + latitude: float | int | None + longitude: float | int | None + type: GeomType = GeomType.Point } class GeoreferenceResult { likely_CRSs: list[str] = list - map_area: Optional[Area_Extraction] = None + map_area: Area_Extraction | None = None projections: list[ProjectionResult] = list } + class Pixel_Point { + rows_from_top: float | int + columns_from_left: float | int + type: GeomType = GeomType.Point + } + class GeomType { <> Point: str = 'Point' @@ -153,36 +150,46 @@ classDiagram Polygon: str = 'Polygon' } - class Pixel_Point { - rows_from_top: Union[float, int] - columns_from_left: Union[float, int] - type: GeomType = GeomType.Point + class Area_Extraction { + type: GeomType = GeomType.Polygon + coordinates: list[list[list[float | int]]] + bbox: list[float | int] = list + category: AreaType + text: str = '' + reference_id: str = '' + validated: bool = False + model: str + model_version: str + confidence: float | int | None = None } - class GeoreferenceResults { - cog_id: str - georeference_results: list[GeoreferenceResult] = list - gcps: list[GroundControlPoint] = list - system: str - system_version: str + class ProjectionResult { + crs: str + gcp_ids: list[str] + file_name: str + validated: bool = False } - class Geom_Point { - latitude: Union[float, int, NoneType] - longitude: Union[float, int, NoneType] - type: GeomType = GeomType.Point + class GroundControlPoint { + gcp_id: str + map_geom: Geom_Point + px_geom: Pixel_Point + confidence: float | int | None = None + model: str + model_version: str + crs: str } - Area_Extraction ..> AreaType Area_Extraction ..> GeomType + Area_Extraction ..> AreaType Geom_Point ..> GeomType Pixel_Point ..> GeomType GroundControlPoint ..> Pixel_Point GroundControlPoint ..> Geom_Point GeoreferenceResult ..> Area_Extraction GeoreferenceResult ..> ProjectionResult - GeoreferenceResults ..> GroundControlPoint GeoreferenceResults ..> GeoreferenceResult + GeoreferenceResults ..> GroundControlPoint ``` @@ -197,36 +204,28 @@ classDiagram ```mermaid classDiagram + class MapShapeTypes { + <> + rectangular: str = 'rectangular' + non_rectangular: str = 'non_rectangular' + } + class MapMetaData { title: str = '' - year: Optional[int] = None + year: int | None = None crs: str = '' authors: list[str] = list organization: str = '' - scale: Optional[int] = None + scale: int | None = None quadrangle_name: str = '' - map_shape: Optional[MapShapeTypes] = None - map_color_scheme: Optional[MapColorSchemeTypes] = None + map_shape: MapShapeTypes | None = None + map_color_scheme: MapColorSchemeTypes | None = None publisher: str = '' state: str = '' model: str model_version: str } - class CogMetaData { - cog_id: str - system: str - system_version: str - multiple_maps: Optional[bool] = None - map_metadata: list[MapMetaData] = list - } - - class MapShapeTypes { - <> - rectangular: str = 'rectangular' - non_rectangular: str = 'non_rectangular' - } - class MapColorSchemeTypes { <> full_color: str = 'full_color' @@ -234,6 +233,14 @@ classDiagram grayscale: str = 'grayscale' } + class CogMetaData { + cog_id: str + system: str + system_version: str + multiple_maps: bool | None = None + map_metadata: list[MapMetaData] = list + } + MapMetaData ..> MapShapeTypes MapMetaData ..> MapColorSchemeTypes CogMetaData ..> MapMetaData @@ -251,27 +258,61 @@ classDiagram ```mermaid classDiagram - class LineLegendAndFeaturesResult { + class PolygonLegendAndFeaturesResult { id: str - legend_provenance: Optional[ModelProvenance] = None - name: str = '' + legend_provenance: ModelProvenance | None = None + label: str abbreviation: str = '' description: str = '' - legend_bbox: list[Union[float, int]] = list - legend_contour: list[list[Union[float, int]]] = list + legend_bbox: list[float | int] = list + legend_contour: list[list[float | int]] = list + color: str = '' + pattern: str = '' + category: str = '' + map_unit: MapUnit | None = None + reference_id: str = '' + validated: bool = False crs: str = 'pixel' cdr_projection_id: str = '' - line_features: Optional[LineFeatureCollection] = None + polygon_features: PolygonFeatureCollection | None = None + } + + class Area_Extraction { + type: GeomType = GeomType.Polygon + coordinates: list[list[list[float | int]]] + bbox: list[float | int] = list + category: AreaType + text: str = '' + reference_id: str = '' + validated: bool = False + model: str + model_version: str + confidence: float | int | None = None } class CogMetaData { cog_id: str system: str system_version: str - multiple_maps: Optional[bool] = None + multiple_maps: bool | None = None map_metadata: list[MapMetaData] = list } + class LineLegendAndFeaturesResult { + id: str + legend_provenance: ModelProvenance | None = None + name: str = '' + abbreviation: str = '' + description: str = '' + legend_bbox: list[float | int] = list + legend_contour: list[list[float | int]] = list + reference_id: str = '' + validated: bool = False + crs: str = 'pixel' + cdr_projection_id: str = '' + line_features: LineFeatureCollection | None = None + } + class FeatureResults { system: str system_version: str @@ -283,61 +324,35 @@ classDiagram cog_metadata_extractions: list[CogMetaData] = list } - class PolygonLegendAndFeaturesResult { - id: str - legend_provenance: Optional[ModelProvenance] = None - label: str - abbreviation: str = '' - description: str = '' - legend_bbox: list[Union[float, int]] = list - legend_contour: list[list[Union[float, int]]] = list - color: str = '' - pattern: str = '' - category: str = '' - map_unit: Optional[MapUnit] = None - crs: str = 'pixel' - cdr_projection_id: str = '' - polygon_features: Optional[PolygonFeatureCollection] = None - } - - class Area_Extraction { - type: GeomType = GeomType.Polygon - coordinates: list[list[list[Union[float, int]]]] - bbox: list[Union[float, int]] = list - category: AreaType - text: str = '' - model: str - model_version: str - confidence: Union[float, int, NoneType] = None - } - class PointLegendAndFeaturesResult { id: str - legend_provenance: Optional[ModelProvenance] = None + legend_provenance: ModelProvenance | None = None name: str abbreviation: str = '' description: str = '' - legend_bbox: list[Union[float, int]] = list - legend_contour: list[list[Union[float, int]]] = list + legend_bbox: list[float | int] = list + legend_contour: list[list[float | int]] = list + reference_id: str = '' + validated: bool = False crs: str = 'pixel' cdr_projection_id: str = '' - point_features: Optional[PointFeatureCollection] = None + point_features: PointFeatureCollection | None = None } - Area_Extraction ..> AreaType Area_Extraction ..> GeomType - LineLegendAndFeaturesResult ..> ModelProvenance + Area_Extraction ..> AreaType LineLegendAndFeaturesResult ..> LineFeatureCollection + LineLegendAndFeaturesResult ..> ModelProvenance PointLegendAndFeaturesResult ..> PointFeatureCollection PointLegendAndFeaturesResult ..> ModelProvenance - PolygonLegendAndFeaturesResult ..> PolygonFeatureCollection - PolygonLegendAndFeaturesResult ..> MapUnit PolygonLegendAndFeaturesResult ..> ModelProvenance + PolygonLegendAndFeaturesResult ..> MapUnit + PolygonLegendAndFeaturesResult ..> PolygonFeatureCollection CogMetaData ..> MapMetaData - FeatureResults ..> LineLegendAndFeaturesResult + FeatureResults ..> Area_Extraction FeatureResults ..> CogMetaData FeatureResults ..> PolygonLegendAndFeaturesResult - FeatureResults ..> Area_Extraction + FeatureResults ..> LineLegendAndFeaturesResult FeatureResults ..> PointLegendAndFeaturesResult @@ -356,10 +371,12 @@ classDiagram class PointProperties { model: str model_version: str - confidence: Union[float, int, NoneType] = None - bbox: Optional[list[Union[float, int]]] = None - dip: Optional[int] = None - dip_direction: Optional[int] = None + confidence: float | int | None = None + bbox: list[float | int] | None = None + dip: int | None = None + dip_direction: int | None = None + reference_id: str = '' + validated: bool = False } class PointFeatureCollection { @@ -367,12 +384,6 @@ classDiagram features: list[PointFeature] = list } - class GeoJsonType { - <> - Feature: str = 'Feature' - FeatureCollection: str = 'FeatureCollection' - } - class PointFeature { type: GeoJsonType = GeoJsonType.Feature id: str @@ -387,36 +398,44 @@ classDiagram Polygon: str = 'Polygon' } + class Point { + coordinates: list[float | int] + type: GeomType = GeomType.Point + } + + class GeoJsonType { + <> + Feature: str = 'Feature' + FeatureCollection: str = 'FeatureCollection' + } + class ModelProvenance { model: str model_version: str - confidence: Union[float, int, NoneType] = None - } - - class Point { - coordinates: list[Union[float, int]] - type: GeomType = GeomType.Point + confidence: float | int | None = None } class PointLegendAndFeaturesResult { id: str - legend_provenance: Optional[ModelProvenance] = None + legend_provenance: ModelProvenance | None = None name: str abbreviation: str = '' description: str = '' - legend_bbox: list[Union[float, int]] = list - legend_contour: list[list[Union[float, int]]] = list + legend_bbox: list[float | int] = list + legend_contour: list[list[float | int]] = list + reference_id: str = '' + validated: bool = False crs: str = 'pixel' cdr_projection_id: str = '' - point_features: Optional[PointFeatureCollection] = None + point_features: PointFeatureCollection | None = None } Point ..> GeomType - PointFeature ..> GeoJsonType PointFeature ..> PointProperties PointFeature ..> Point - PointFeatureCollection ..> GeoJsonType + PointFeature ..> GeoJsonType PointFeatureCollection ..> PointFeature + PointFeatureCollection ..> GeoJsonType PointLegendAndFeaturesResult ..> PointFeatureCollection PointLegendAndFeaturesResult ..> ModelProvenance @@ -433,14 +452,6 @@ classDiagram ```mermaid classDiagram - class LineProperty { - model: str - model_version: str - confidence: Union[float, int, NoneType] = None - dash_pattern: Optional[DashType] = None - symbol: str = '' - } - class LineFeature { type: GeoJsonType = GeoJsonType.Feature id: str @@ -448,10 +459,9 @@ classDiagram properties: LineProperty } - class GeoJsonType { - <> - Feature: str = 'Feature' - FeatureCollection: str = 'FeatureCollection' + class Line { + coordinates: list[list[float | int]] + type: GeomType = GeomType.LineString } class GeomType { @@ -461,10 +471,17 @@ classDiagram Polygon: str = 'Polygon' } - class ModelProvenance { - model: str - model_version: str - confidence: Union[float, int, NoneType] = None + class DashType { + <> + solid: str = 'solid' + dash: str = 'dash' + dotted: str = 'dotted' + } + + class GeoJsonType { + <> + Feature: str = 'Feature' + FeatureCollection: str = 'FeatureCollection' } class LineFeatureCollection { @@ -474,38 +491,44 @@ classDiagram class LineLegendAndFeaturesResult { id: str - legend_provenance: Optional[ModelProvenance] = None + legend_provenance: ModelProvenance | None = None name: str = '' abbreviation: str = '' description: str = '' - legend_bbox: list[Union[float, int]] = list - legend_contour: list[list[Union[float, int]]] = list + legend_bbox: list[float | int] = list + legend_contour: list[list[float | int]] = list + reference_id: str = '' + validated: bool = False crs: str = 'pixel' cdr_projection_id: str = '' - line_features: Optional[LineFeatureCollection] = None + line_features: LineFeatureCollection | None = None } - class DashType { - <> - solid: str = 'solid' - dash: str = 'dash' - dotted: str = 'dotted' + class ModelProvenance { + model: str + model_version: str + confidence: float | int | None = None } - class Line { - coordinates: list[list[Union[float, int]]] - type: GeomType = GeomType.LineString + class LineProperty { + model: str + model_version: str + confidence: float | int | None = None + dash_pattern: DashType | None = None + symbol: str = '' + reference_id: str = '' + validated: bool = False } Line ..> GeomType LineProperty ..> DashType + LineFeature ..> Line LineFeature ..> LineProperty LineFeature ..> GeoJsonType - LineFeature ..> Line LineFeatureCollection ..> LineFeature LineFeatureCollection ..> GeoJsonType - LineLegendAndFeaturesResult ..> ModelProvenance LineLegendAndFeaturesResult ..> LineFeatureCollection + LineLegendAndFeaturesResult ..> ModelProvenance ``` @@ -520,38 +543,16 @@ classDiagram ```mermaid classDiagram - class MapUnit { - age_text: str = '' - b_age: Optional[float] = None - b_interval: str = '' - lithology: str = '' - name: str = '' - t_age: Optional[float] = None - t_interval: str = '' - comments: str = '' - } - - class PolygonLegendAndFeaturesResult { + class PolygonFeature { + type: GeoJsonType = GeoJsonType.Feature id: str - legend_provenance: Optional[ModelProvenance] = None - label: str - abbreviation: str = '' - description: str = '' - legend_bbox: list[Union[float, int]] = list - legend_contour: list[list[Union[float, int]]] = list - color: str = '' - pattern: str = '' - category: str = '' - map_unit: Optional[MapUnit] = None - crs: str = 'pixel' - cdr_projection_id: str = '' - polygon_features: Optional[PolygonFeatureCollection] = None + geometry: Polygon + properties: PolygonProperty } - class GeoJsonType { - <> - Feature: str = 'Feature' - FeatureCollection: str = 'FeatureCollection' + class Polygon { + coordinates: list[list[list[float | int]]] + type: GeomType = GeomType.Polygon } class GeomType { @@ -561,21 +562,54 @@ classDiagram Polygon: str = 'Polygon' } - class ModelProvenance { + class PolygonProperty { model: str model_version: str - confidence: Union[float, int, NoneType] = None + reference_id: str = '' + validated: bool = False + confidence: float | int | None = None } - class PolygonProperty { + class GeoJsonType { + <> + Feature: str = 'Feature' + FeatureCollection: str = 'FeatureCollection' + } + + class PolygonLegendAndFeaturesResult { + id: str + legend_provenance: ModelProvenance | None = None + label: str + abbreviation: str = '' + description: str = '' + legend_bbox: list[float | int] = list + legend_contour: list[list[float | int]] = list + color: str = '' + pattern: str = '' + category: str = '' + map_unit: MapUnit | None = None + reference_id: str = '' + validated: bool = False + crs: str = 'pixel' + cdr_projection_id: str = '' + polygon_features: PolygonFeatureCollection | None = None + } + + class ModelProvenance { model: str model_version: str - confidence: Union[float, int, NoneType] = None + confidence: float | int | None = None } - class Polygon { - coordinates: list[list[list[Union[float, int]]]] - type: GeomType = GeomType.Polygon + class MapUnit { + age_text: str = '' + b_age: float | None = None + b_interval: str = '' + lithology: str = '' + name: str = '' + t_age: float | None = None + t_interval: str = '' + comments: str = '' } class PolygonFeatureCollection { @@ -583,22 +617,15 @@ classDiagram features: list[PolygonFeature] = list } - class PolygonFeature { - type: GeoJsonType = GeoJsonType.Feature - id: str - geometry: Polygon - properties: PolygonProperty - } - Polygon ..> GeomType PolygonFeature ..> Polygon - PolygonFeature ..> GeoJsonType PolygonFeature ..> PolygonProperty - PolygonFeatureCollection ..> GeoJsonType + PolygonFeature ..> GeoJsonType PolygonFeatureCollection ..> PolygonFeature - PolygonLegendAndFeaturesResult ..> PolygonFeatureCollection - PolygonLegendAndFeaturesResult ..> MapUnit + PolygonFeatureCollection ..> GeoJsonType PolygonLegendAndFeaturesResult ..> ModelProvenance + PolygonLegendAndFeaturesResult ..> MapUnit + PolygonLegendAndFeaturesResult ..> PolygonFeatureCollection ``` @@ -613,36 +640,28 @@ classDiagram ```mermaid classDiagram + class MapShapeTypes { + <> + rectangular: str = 'rectangular' + non_rectangular: str = 'non_rectangular' + } + class MapMetaData { title: str = '' - year: Optional[int] = None + year: int | None = None crs: str = '' authors: list[str] = list organization: str = '' - scale: Optional[int] = None + scale: int | None = None quadrangle_name: str = '' - map_shape: Optional[MapShapeTypes] = None - map_color_scheme: Optional[MapColorSchemeTypes] = None + map_shape: MapShapeTypes | None = None + map_color_scheme: MapColorSchemeTypes | None = None publisher: str = '' state: str = '' model: str model_version: str } - class CogMetaData { - cog_id: str - system: str - system_version: str - multiple_maps: Optional[bool] = None - map_metadata: list[MapMetaData] = list - } - - class MapShapeTypes { - <> - rectangular: str = 'rectangular' - non_rectangular: str = 'non_rectangular' - } - class MapColorSchemeTypes { <> full_color: str = 'full_color' @@ -650,6 +669,14 @@ classDiagram grayscale: str = 'grayscale' } + class CogMetaData { + cog_id: str + system: str + system_version: str + multiple_maps: bool | None = None + map_metadata: list[MapMetaData] = list + } + MapMetaData ..> MapShapeTypes MapMetaData ..> MapColorSchemeTypes CogMetaData ..> MapMetaData @@ -667,6 +694,18 @@ classDiagram ```mermaid classDiagram + class DocumentMetaData { + doi: str = '' + authors: list[str] = list + journal: str = '' + year: int | None = None + month: int | None = None + volume: int | None = None + issue: str = '' + description: str = '' + publisher: str = '' + } + class DocumentProvenance { external_system_name: str external_system_id: str = '' @@ -677,21 +716,21 @@ classDiagram title: str is_open: bool = True provenance: list[DocumentProvenance] = list - metadata: Optional[DocumentMetaData] = None + metadata: DocumentMetaData | None = None system: str system_version: str } class DocumentExtraction { - id: UnionType[str, NoneType] = None + id: str | None = None document_id: str = None extraction_type: str extraction_label: str - score: UnionType[float, NoneType] = None - bbox: UnionType[tuple[float, float, float, float], NoneType] = None - page_num: UnionType[int, NoneType] = None - external_link: UnionType[str, NoneType] = None - data: Optional[dict[]] = None + score: float | None = None + bbox: tuple[float, float, float, float] | None = None + page_num: int | None = None + external_link: str | None = None + data: dict[] | None = None system: str system_version: str } @@ -703,27 +742,15 @@ classDiagram pages: int size: int provenance: list[DocumentProvenance] = list - metadata: Optional[DocumentMetaData] = None + metadata: DocumentMetaData | None = None system: str system_version: str } - class DocumentMetaData { - doi: str = '' - authors: list[str] = list - journal: str = '' - year: Optional[int] = None - month: Optional[int] = None - volume: Optional[int] = None - issue: str = '' - description: str = '' - publisher: str = '' - } - - UploadDocument ..> DocumentProvenance UploadDocument ..> DocumentMetaData - Document ..> DocumentProvenance + UploadDocument ..> DocumentProvenance Document ..> DocumentMetaData + Document ..> DocumentProvenance ``` @@ -738,11 +765,28 @@ classDiagram ```mermaid classDiagram - class DepositTypeCandidate { - observed_name: str - normalized_uri: DepositType - confidence: Union[float, int, NoneType] - source: str + class PageInfo { + page: int + bounding_box: BoundingBox | None + } + + class Document { + id: str + title: str + is_open: bool + pages: int + size: int + provenance: list[DocumentProvenance] = list + metadata: DocumentMetaData | None = None + system: str + system_version: str + } + + class LocationInfo { + location: Geometry + crs: str + country: str = '' + state_or_province: str | None } class EvidenceLayer { @@ -750,14 +794,14 @@ classDiagram relevance_score: float } - class GeologyInfo { - age: str = '' - unit_name: str = '' - description: str = '' - lithology: list[str] = list - process: list[str] = list - environment: list[str] = list - comments: str = '' + class Commodity { + name: str + } + + class Geometry { + <> + Point: str = 'Point' + Polygon: str = 'Polygon' } class Grade { @@ -765,10 +809,16 @@ classDiagram grade_value: float } - class DepositType { - name: str - environment: str - group: str + class DepositTypeCandidate { + observed_name: str + normalized_uri: DepositType + confidence: float | int | None + source: str + } + + class Ore { + ore_unit: str + ore_value: float } class BoundingBox { @@ -778,77 +828,24 @@ classDiagram y_max: float } - class MappableCriteria { - criteria: str - theoretical: str = '' - potential_dataset: list[EvidenceLayer] = list - supporting_references: list[Reference] - } - - class Commodity { - name: str - } - class MineralInventory { commodity: Commodity observed_commodity: str = '' - category: Optional[ResourceReserveCategory] - ore: Optional[Ore] - grade: Optional[Grade] - cutoff_grade: Optional[Grade] - contained_metal: Optional[float] + category: ResourceReserveCategory | None + ore: Ore | None + grade: Grade | None + cutoff_grade: Grade | None + contained_metal: float | None reference: Reference - date: Optional[datetime] + date: datetime | None zone: str = '' } - class PageInfo { - page: int - bounding_box: Optional[BoundingBox] - } - - class LocationInfo { - location: Geometry - crs: str - country: str = '' - state_or_province: Optional[str] - } - - class Ore { - ore_unit: str - ore_value: float - } - - class ResourceReserveCategory { - <> - INFERRED: str = 'Inferred Mineral Resource' - INDICATED: str = 'Indicated Mineral Resource' - MEASURED: str = 'Measured Mineral Resource' - PROBABLE: str = 'Probable Mineral Reserve' - PROVEN: str = 'Proven Mineral Reserve' - } - - class Document { - id: str - title: str - is_open: bool - pages: int - size: int - provenance: list[DocumentProvenance] = list - metadata: Optional[DocumentMetaData] = None - system: str - system_version: str - } - - class Geometry { - <> - Point: str = 'Point' - Polygon: str = 'Polygon' - } - - class Reference { - document: Document - page_info: list[PageInfo] = list + class MappableCriteria { + criteria: str + theoretical: str = '' + potential_dataset: list[EvidenceLayer] = list + supporting_references: list[Reference] } class MineralSystem { @@ -861,37 +858,67 @@ classDiagram outflow: list[MappableCriteria] = list } + class GeologyInfo { + age: str = '' + unit_name: str = '' + description: str = '' + lithology: list[str] = list + process: list[str] = list + environment: list[str] = list + comments: str = '' + } + + class DepositType { + name: str + environment: str + group: str + } + class MineralSite { source_id: str record_id: str name: str = '' mineral_inventory: list[MineralInventory] location_info: LocationInfo - geology_info: Optional[GeologyInfo] + geology_info: GeologyInfo | None deposit_type_candidate: list[DepositTypeCandidate] } - Document ..> DocumentProvenance + class Reference { + document: Document + page_info: list[PageInfo] = list + } + + class ResourceReserveCategory { + <> + INFERRED: str = 'Inferred Mineral Resource' + INDICATED: str = 'Indicated Mineral Resource' + MEASURED: str = 'Measured Mineral Resource' + PROBABLE: str = 'Probable Mineral Reserve' + PROVEN: str = 'Proven Mineral Reserve' + } + Document ..> DocumentMetaData + Document ..> DocumentProvenance DepositTypeCandidate ..> DepositType PageInfo ..> BoundingBox - Reference ..> Document Reference ..> PageInfo - MappableCriteria ..> Reference + Reference ..> Document MappableCriteria ..> EvidenceLayer - MineralSystem ..> MappableCriteria + MappableCriteria ..> Reference MineralSystem ..> DepositType - MineralInventory ..> Grade + MineralSystem ..> MappableCriteria + MineralInventory ..> Reference MineralInventory ..> Ore + MineralInventory ..> Grade + MineralInventory ..> Commodity MineralInventory ..> ResourceReserveCategory - MineralInventory ..> Reference MineralInventory ..> datetime - MineralInventory ..> Commodity LocationInfo ..> Geometry MineralSite ..> GeologyInfo MineralSite ..> DepositTypeCandidate - MineralSite ..> LocationInfo MineralSite ..> MineralInventory + MineralSite ..> LocationInfo ``` @@ -906,6 +933,14 @@ classDiagram ```mermaid classDiagram + class GeoreferenceResults { + cog_id: str + georeference_results: list[GeoreferenceResult] = list + gcps: list[GroundControlPoint] = list + system: str + system_version: str + } + class MapResults { cog_id: str georef_results: list[GeoreferenceResults] = list @@ -923,23 +958,15 @@ classDiagram cog_metadata_extractions: list[CogMetaData] = list } - class GeoreferenceResults { - cog_id: str - georeference_results: list[GeoreferenceResult] = list - gcps: list[GroundControlPoint] = list - system: str - system_version: str - } - - FeatureResults ..> LineLegendAndFeaturesResult + FeatureResults ..> Area_Extraction FeatureResults ..> CogMetaData FeatureResults ..> PolygonLegendAndFeaturesResult - FeatureResults ..> Area_Extraction + FeatureResults ..> LineLegendAndFeaturesResult FeatureResults ..> PointLegendAndFeaturesResult - GeoreferenceResults ..> GroundControlPoint GeoreferenceResults ..> GeoreferenceResult - MapResults ..> FeatureResults + GeoreferenceResults ..> GroundControlPoint MapResults ..> GeoreferenceResults + MapResults ..> FeatureResults ``` @@ -954,12 +981,6 @@ classDiagram ```mermaid classDiagram - class MapProvenance { - system_name: str - id: str = None - url: str = None - } - class Map { id: str provenance: list[MapProvenance] = list @@ -968,9 +989,221 @@ classDiagram system_version: str } + class MapProvenance { + system_name: str + id: str = None + url: str = None + } + Map ..> MapProvenance +``` + + + +### Prospectivity Input + +
+ prospectivity input + +```mermaid +classDiagram + + class DataFormat { + <> + TIF: str = 'tif' + SHP: str = 'shp' + } + + class InterpolationType { + <> + LINEAR: str = 'linear' + CUBIC: str = 'cubic' + NEAREST: str = 'nearest' + NONE: str = 'none' + } + + class StackMetaData { + title: str | None + year: int | None + crs: str | None + authors: list[str] | None + organization: str | None + scale: int | None + evidence_layers: list[ProcessedDataLayer] + } + + class LayerDataType { + <> + CONTINUOUS: str = 'continuous' + BINARY: str = 'binary' + } + + class ScalingType { + <> + MINMAX: str = 'minmax' + MAXABS: str = 'maxabs' + STANDARD: str = 'standard' + } + + class ProcessedDataLayer { + title: str | None + resampling_method: InterpolationType + scaling_method: ScalingType + normalization_method: str + } + + class LayerCategory { + <> + GEOPHYSICS: str = 'geophysics' + GEOLOGY: str = 'geology' + GEOCHEMISTRY: str = 'geochemistry' + } + + class DataSource { + DOI: str | None + authors: list[str] | None + publication_date: str | None + category: LayerCategory | str | None + subcategory: str | None + description: str | None + derivative_ops: str | None + type: LayerDataType + resolution: tuple | None + format: DataFormat + download_url: str | None + } + + DataSource ..> LayerDataType + DataSource ..> DataFormat + DataSource ..> tuple + DataSource ..> LayerCategory + ProcessedDataLayer ..> ScalingType + ProcessedDataLayer ..> InterpolationType + StackMetaData ..> ProcessedDataLayer + + +``` + +
+ +### Prospectivity Models + +
+ prospectivity models + +```mermaid +classDiagram + + class CMAModel { + title: str | None + date: int | None + authors: list[str] | None + organization: str | None + cma_model_type: NeuralNetModel | SOMModel + training_data: StackMetaData + } + + class SOMGrid { + <> + HEXAGONAL: str = 'hexagonal' + RECTANGULAR: str = 'rectangular' + } + + class NeuralNetModel { + train_config: NeuralNetTrainConfig + } + + class Accelerator { + <> + CPU: str = 'cpu' + GPU: str = 'gpu' + } + + class StackMetaData { + title: str | None + year: int | None + crs: str | None + authors: list[str] | None + organization: str | None + scale: int | None + evidence_layers: list[ProcessedDataLayer] + } + + class SOMModel { + train_config: SOMTrainConfig + } + + class NeighborhoodDecay { + <> + LINEAR: str = 'linear' + EXPONENTIAL: str = 'exponential' + } + + class LearningRateDecay { + <> + LINEAR: str = 'linear' + EXPONENTIAL: str = 'exponential' + } + + class SOMTrainConfig { + dimensions_x: int + dimensions_y: int + num_epochs: int + num_initializations: int + neighborhood_function: NeighborhoodFunction + som_type: SOMType + neighborhood_decay: NeighborhoodDecay + learning_rate_decay: LearningRateDecay + initial_learning_rate: float + final_learning_rate: float + som_initialization: SOMInitialization + som_grid: SOMGrid + } + + class SOMInitialization { + <> + RANDOM: str = 'random' + PCA: str = 'pca' + } + + class SOMType { + <> + TOROID: str = 'toroid' + SHEET: str = 'sheet' + } + + class NeighborhoodFunction { + <> + GAUSSIAN: str = 'gaussian' + BUBBLE: str = 'bubble' + } + + class NeuralNetTrainConfig { + min_epochs: int + max_epochs: int + accelerator: Accelerator + precision: int + val_check_interval: float + deterministic: bool + } + + StackMetaData ..> ProcessedDataLayer + NeuralNetTrainConfig ..> Accelerator + SOMTrainConfig ..> SOMInitialization + SOMTrainConfig ..> SOMGrid + SOMTrainConfig ..> SOMType + SOMTrainConfig ..> NeighborhoodFunction + SOMTrainConfig ..> NeighborhoodDecay + SOMTrainConfig ..> LearningRateDecay + NeuralNetModel ..> NeuralNetTrainConfig + SOMModel ..> SOMTrainConfig + CMAModel ..> StackMetaData + CMAModel ..> NeuralNetModel + CMAModel ..> SOMModel + + ```
diff --git a/cdr_schemas/prospectivity_input.py b/cdr_schemas/prospectivity_input.py new file mode 100644 index 0000000..19f0a3a --- /dev/null +++ b/cdr_schemas/prospectivity_input.py @@ -0,0 +1,99 @@ +from enum import Enum +from typing import List, Optional, Union + +from pydantic import BaseModel, Field + + +class InterpolationType(str, Enum): + """Enum for the possible values of type field of MapUnit""" + + LINEAR = "linear" + CUBIC = "cubic" + NEAREST = "nearest" + NONE = "none" + + +class ScalingType(str, Enum): + """Enum for the possible values of type field of MapUnit""" + + MINMAX = "minmax" + MAXABS = "maxabs" + STANDARD = "standard" + + +class LayerCategory(str, Enum): + GEOPHYSICS = "geophysics" + GEOLOGY = "geology" + GEOCHEMISTRY = "geochemistry" + + +class LayerDataType(str, Enum): + CONTINUOUS = "continuous" + BINARY = "binary" + + +class DataFormat(str, Enum): + TIF = "tif" + SHP = "shp" + + +class DataSource(BaseModel): + DOI: Optional[str] + authors: Optional[List[str]] + publication_date: Optional[str] + category: Optional[Union[LayerCategory, str]] + subcategory: Optional[str] + description: Optional[str] + derivative_ops: Optional[str] + type: LayerDataType + resolution: Optional[tuple] + format: DataFormat + download_url: Optional[str] + + +class ProcessedDataLayer(BaseModel): + title: Optional[str] + resampling_method: InterpolationType + scaling_method: ScalingType + normalization_method: str # source: LayerDataType + + +class StackMetaData(BaseModel): + title: Optional[str] = Field( + ..., + description=""" + Title of the map/cog. + """, + ) + year: Optional[int] = Field( + ..., + description=""" + Year the map was made. i.e. 2012 + """, + ) + crs: Optional[str] = Field( + ..., + description=""" + CRS of the map. i.e. "EPSG:4267" + """, + ) + authors: Optional[List[str]] = Field( + ..., + description=""" + Creators of the dataset + """, + ) + organization: Optional[str] = Field( + ..., + description=""" + Organization that created the map + """, + ) + scale: Optional[int] = Field( + ..., + description=""" + Mean scale of the map. 24000 would be equivalent to 1:24000. + """, + ) + + evidence_layers: List[ProcessedDataLayer] diff --git a/cdr_schemas/prospectivity_models.py b/cdr_schemas/prospectivity_models.py new file mode 100644 index 0000000..fe0d4be --- /dev/null +++ b/cdr_schemas/prospectivity_models.py @@ -0,0 +1,113 @@ +from enum import Enum +from typing import List, Optional, Union + +from pydantic import BaseModel, Field + +from .prospectivity_input import StackMetaData + + +class Accelerator(str, Enum): + CPU = "cpu" + GPU = "gpu" + + +class NeuralNetTrainConfig(BaseModel): + min_epochs: int # prevents early stopping + max_epochs: int + + accelerator: Accelerator + + # mixed precision for extra speed-up + precision: int + + # perform a validation loop twice every training epoch + val_check_interval: float + + # set True to to ensure deterministic results + # makes training slower but gives more reproducibility than just setting seeds + deterministic: bool + + +class NeighborhoodFunction(str, Enum): + GAUSSIAN = "gaussian" + BUBBLE = "bubble" + + +class SOMType(str, Enum): + TOROID = "toroid" + SHEET = "sheet" + + +class NeighborhoodDecay(str, Enum): + LINEAR = "linear" + EXPONENTIAL = "exponential" + + +class LearningRateDecay(str, Enum): + LINEAR = "linear" + EXPONENTIAL = "exponential" + + +class SOMInitialization(str, Enum): + RANDOM = "random" + PCA = "pca" + + +class SOMGrid(str, Enum): + HEXAGONAL = "hexagonal" + RECTANGULAR = "rectangular" + + +class SOMTrainConfig(BaseModel): + dimensions_x: int + dimensions_y: int + num_epochs: int + num_initializations: int + neighborhood_function: NeighborhoodFunction + som_type: SOMType + neighborhood_decay: NeighborhoodDecay + learning_rate_decay: LearningRateDecay + initial_learning_rate: float + final_learning_rate: float + som_initialization: SOMInitialization + som_grid: SOMGrid + + +class NeuralNetModel(BaseModel): + train_config: NeuralNetTrainConfig + pass + + +class SOMModel(BaseModel): + train_config: SOMTrainConfig + pass + + +class CMAModel(BaseModel): + title: Optional[str] = Field( + ..., + description=""" + Title of the model. + """, + ) + date: Optional[int] = Field( + ..., + description=""" + Date that the model was made. i.e. 2012 + """, + ) + authors: Optional[List[str]] = Field( + ..., + description=""" + Creators of the model + """, + ) + organization: Optional[str] = Field( + ..., + description=""" + Organization that created the model + """, + ) + cma_model_type: Union[NeuralNetModel, SOMModel] + + training_data: StackMetaData diff --git a/dev/docs.py b/dev/docs.py index d4dffd3..ee257d2 100644 --- a/dev/docs.py +++ b/dev/docs.py @@ -18,6 +18,8 @@ import cdr_schemas.map_results import cdr_schemas.metadata import cdr_schemas.mineral +import cdr_schemas.prospectivity_input +import cdr_schemas.prospectivity_models @dataclass @@ -69,6 +71,8 @@ def run(): Module(title="mineral", ref=cdr_schemas.mineral), Module(title="map results", ref=cdr_schemas.map_results), Module(title="map", ref=cdr_schemas.map), + Module(title="prospectivity input", ref=cdr_schemas.prospectivity_input), + Module(title="prospectivity models", ref=cdr_schemas.prospectivity_models), ] for m in modules: From d1651ad1c05bfd7be7fbb908ca84e4db17d9d65b Mon Sep 17 00:00:00 2001 From: marshHawk4 Date: Fri, 21 Jun 2024 12:00:43 -0400 Subject: [PATCH 2/8] Cdr response objects (#37) * Adding CDR response objects --- cdr_schemas/cdr_responses/area_extractions.py | 48 +++++++ cdr_schemas/cdr_responses/features.py | 133 ++++++++++++++++++ cdr_schemas/cdr_responses/legend_items.py | 61 ++++++++ pyproject.toml | 5 +- 4 files changed, 245 insertions(+), 2 deletions(-) create mode 100644 cdr_schemas/cdr_responses/area_extractions.py create mode 100644 cdr_schemas/cdr_responses/features.py create mode 100644 cdr_schemas/cdr_responses/legend_items.py diff --git a/cdr_schemas/cdr_responses/area_extractions.py b/cdr_schemas/cdr_responses/area_extractions.py new file mode 100644 index 0000000..e12054f --- /dev/null +++ b/cdr_schemas/cdr_responses/area_extractions.py @@ -0,0 +1,48 @@ +from typing import List, Optional, Union + +from pydantic import BaseModel, Field + +from cdr_schemas.area_extraction import AreaType +from cdr_schemas.cdr_responses.features import ProjectedFeature +from cdr_schemas.features.polygon_features import Polygon + + +class AreaExtractionResponse(BaseModel): + area_extraction_id: str = Field(default="", description="Area extraction id") + cog_id: str = Field(default="", description="Cog id") + reference_id: Union[str, None] = Field( + default=None, description="Legend id of older version of this legend item." + ) + px_bbox: List[Union[float, int]] = Field( + default_factory=list, + description="""The rough 2 point bounding box of the item. + Format is expected to be [x1,y1,x2,y2].""", + ) + px_geojson: Optional[Polygon] + system: str = Field(default="", description="System that published this item") + system_version: str = Field( + default="", description="System version that published this item" + ) + model_id: str = Field( + default="", description="Model id for the model used to generate this item" + ) + validated: bool = Field(default=False, description="Validated by human") + confidence: Optional[float] = None + category: AreaType = Field( + ..., + description=""" + The type of area extraction. + """, + ) + text: str = Field( + default="", + description=""" + The text within the extraction area. + """, + ) + projected_feature: List[ProjectedFeature] = Field( + default_factory=list, + description=""" + List of projected versions of this feature. Probably will only be one result. + """, + ) diff --git a/cdr_schemas/cdr_responses/features.py b/cdr_schemas/cdr_responses/features.py new file mode 100644 index 0000000..d36abe6 --- /dev/null +++ b/cdr_schemas/cdr_responses/features.py @@ -0,0 +1,133 @@ +from typing import Any, List, Optional, Union + +from pydantic import BaseModel, Field + +from cdr_schemas.features.line_features import Line +from cdr_schemas.features.point_features import Point +from cdr_schemas.features.polygon_features import Polygon + + +class ProjectedFeature(BaseModel): + cdr_projection_id: str = Field( + description="CDR projection id used for creating transform" + ) + feature_type: str = Field(description="Feature type. E.g. polygon, point, line") + projected_geojson: Optional[Union[Polygon, Point, Line]] = Field( + description="Projected geojson in EPSG 4326" + ) + projected_bbox: List[Union[float, int]] = Field( + default_factory=list, description="Projected bbox in EPSG 4326" + ) + + +class PolygonExtractionResponse(BaseModel): + polygon_id: str = Field(default="", description="CDR polygon id") + cog_id: str = Field(default="", description="Cog id") + px_bbox: List[Union[float, int]] = Field( + default_factory=list, + description="""The rough 2 point bounding box of the item. + Format is expected to be [x1,y1,x2,y2].""", + ) + px_geojson: Polygon + reference_id: Union[str, None] = Field( + default=None, description="Polygon id of older version of this polygon." + ) + confidence: Optional[float] = None + model_id: str = Field( + default="", description="CDR model id for the model used to generate this item" + ) + system: str = Field(default="", description="System that published this item") + system_version: str = Field( + default="", description="System version that published this item" + ) + validated: bool = Field(default=False, description="Validated by human") + legend_id: str = Field(default="", description="Associated CDR legend id") + projected_feature: List[ProjectedFeature] = Field( + default_factory=list, + description=""" + List of projected versions of this feature. Probably will only be one result. + """, + ) + legend_item: Optional[Any] = Field( + default=None, + description="Some CDR endpoints can allow legend item data attached to each feature.", + ) + + +class PointExtractionResponse(BaseModel): + point_id: str = Field(default="", description="CDR point id") + cog_id: str = Field(default="", description="Cog id") + px_bbox: List[Union[float, int]] = Field( + default_factory=list, + description="""The rough 2 point bounding box of the item. + Format is expected to be [x1,y1,x2,y2].""", + ) + px_geojson: Point + dip: Optional[Union[int, None]] = Field( + default=None, description="Point dip value." + ) + dip_direction: Optional[Union[int, None]] = Field( + default=None, description="Point dip direction value." + ) + reference_id: Union[str, None] = Field( + default=None, description="Point id of older version of this point." + ) + confidence: Optional[float] = None + model_id: str = Field( + default="", + description=""" + Model id associated with the model and version used to generate this item + """, + ) + system: str = Field(default="", description="System that published this item") + system_version: str = Field( + default="", description="System Version that published this item" + ) + validated: bool = Field(default=False, description="Validated by human") + legend_id: str = Field(default="", description="Associated legend id") + projected_feature: List[ProjectedFeature] = Field( + default_factory=list, + description=""" + List of projected versions of this feature. Probably will only be one result. + """, + ) + legend_item: Optional[Any] = Field( + default=None, + description="Some CDR endpoints can allow legend item data attached to each feature", + ) + + +class LineExtractionResponse(BaseModel): + line_id: str = Field(default="", description="CDR line id") + cog_id: str = Field(default="", description="Cog id") + px_bbox: List[Union[float, int]] = Field( + default_factory=list, + description="""The rough 2 point bounding box of the item. + Format is expected to be [x1,y1,x2,y2].""", + ) + px_geojson: Line + dash_pattern: str = Field(default="", description="Dash pattern of line") + symbol: str = Field(default="", description="Symbol on line") + reference_id: Union[str, None] = Field( + default=None, description="Line id of older version of this line." + ) + confidence: Optional[float] = None + model_id: str = Field( + default="", description="model id for the model used to generate this item" + ) + system: str = Field(default="", description="System that published this item") + system_version: str = Field( + default="", description="System version that published this item" + ) + validated: bool = Field(default=False, description="Validated by human") + legend_id: str = Field(default="", description="Associated legend id") + projected_feature: List[ProjectedFeature] = Field( + default_factory=list, + description=""" + List of projected versions of this feature. Probably will only be one result. + """, + ) + legend_item: Optional[Any] = Field( + default=None, + description="Some CDR endpoints can allow a legend item data attached to each feature.", + ) diff --git a/cdr_schemas/cdr_responses/legend_items.py b/cdr_schemas/cdr_responses/legend_items.py new file mode 100644 index 0000000..33b634a --- /dev/null +++ b/cdr_schemas/cdr_responses/legend_items.py @@ -0,0 +1,61 @@ +from typing import List, Optional, Union + +from pydantic import BaseModel, Field + +from cdr_schemas.cdr_responses.features import ( + LineExtractionResponse, + PointExtractionResponse, + PolygonExtractionResponse, +) +from cdr_schemas.features.polygon_features import Polygon + + +class LegendItemResponse(BaseModel): + legend_id: str = Field(default="", description="CDR legend id") + abbreviation: str = Field(default="", description="Abbreviation of legend item") + description: str = Field(default="", description="Legend item description") + color: str = Field(default="", description="Color") + reference_id: Union[str, None] = Field( + default=None, description="Legend id of older version of this legend item." + ) + label: str = Field(default="", description="Label of legend item") + pattern: str = Field( + default="", + description="If category of type polygon this can be filled in with pattern type", + ) + px_bbox: List[Union[float, int]] = Field( + default_factory=list, + description="""The rough 2 point bounding box of the item. + Format is expected to be [x1,y1,x2,y2].""", + ) + px_geojson: Optional[Polygon] + cog_id: str = Field(default="", description="Cog id") + category: str = Field( + default="", description="Category of legend item. Polygon, point, or line." + ) + system: str = Field(default="", description="System that published this item") + system_version: str = Field( + default="", description="System version that published this item" + ) + model_id: str = Field( + default="", description="Model id for the model used to generate this item" + ) + validated: bool = Field(default=False, description="Validated by human") + confidence: Optional[float] = None + map_unit_age_text: str = Field(default="", description="Age of map unit") + map_unit_lithology: str = Field(default="", description="Map unit lithology") + map_unit_b_age: Optional[float] = None + map_unit_t_age: Optional[float] = None + + point_extractions: List[PointExtractionResponse] = Field( + default_factory=list, + description="Optionally added point extractions associated with this legend item", + ) + polygon_extractions: List[PolygonExtractionResponse] = Field( + default_factory=list, + description="Optionally added polygon extractions associated with this legend item", + ) + line_extractions: List[LineExtractionResponse] = Field( + default_factory=list, + description="Optionally added line extractions associated with this legend item", + ) diff --git a/pyproject.toml b/pyproject.toml index 21d8e86..fe50db2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,13 @@ [tool.poetry] name = "cdr_schemas" -version = "0.2.9" +version = "0.3.0" description = "CDR Schemas" authors = [] readme = "README.md" packages = [ {include = "cdr_schemas"}, - {include = "cdr_schemas/**/*.py"} + {include = "cdr_schemas/**/*.py"}, + {include = "cdr_schemas/**/**/*.py"} ] [tool.poetry.dependencies] From 5e8c8066dd99839e6e69521a073d27052dfdcb41 Mon Sep 17 00:00:00 2001 From: marshHawk4 Date: Fri, 21 Jun 2024 16:29:13 -0400 Subject: [PATCH 3/8] Update optional requirement (#38) * Adding CDR response objects * updated * features types added * refactor * optional bbox --- cdr_schemas/cdr_responses/area_extractions.py | 2 +- cdr_schemas/cdr_responses/features.py | 6 +++--- cdr_schemas/cdr_responses/legend_items.py | 2 +- pyproject.toml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cdr_schemas/cdr_responses/area_extractions.py b/cdr_schemas/cdr_responses/area_extractions.py index e12054f..878c0a2 100644 --- a/cdr_schemas/cdr_responses/area_extractions.py +++ b/cdr_schemas/cdr_responses/area_extractions.py @@ -13,7 +13,7 @@ class AreaExtractionResponse(BaseModel): reference_id: Union[str, None] = Field( default=None, description="Legend id of older version of this legend item." ) - px_bbox: List[Union[float, int]] = Field( + px_bbox: Optional[List[Union[float, int]]] = Field( default_factory=list, description="""The rough 2 point bounding box of the item. Format is expected to be [x1,y1,x2,y2].""", diff --git a/cdr_schemas/cdr_responses/features.py b/cdr_schemas/cdr_responses/features.py index d36abe6..08536d8 100644 --- a/cdr_schemas/cdr_responses/features.py +++ b/cdr_schemas/cdr_responses/features.py @@ -23,7 +23,7 @@ class ProjectedFeature(BaseModel): class PolygonExtractionResponse(BaseModel): polygon_id: str = Field(default="", description="CDR polygon id") cog_id: str = Field(default="", description="Cog id") - px_bbox: List[Union[float, int]] = Field( + px_bbox: Optional[List[Union[float, int]]] = Field( default_factory=list, description="""The rough 2 point bounding box of the item. Format is expected to be [x1,y1,x2,y2].""", @@ -57,7 +57,7 @@ class PolygonExtractionResponse(BaseModel): class PointExtractionResponse(BaseModel): point_id: str = Field(default="", description="CDR point id") cog_id: str = Field(default="", description="Cog id") - px_bbox: List[Union[float, int]] = Field( + px_bbox: Optional[List[Union[float, int]]] = Field( default_factory=list, description="""The rough 2 point bounding box of the item. Format is expected to be [x1,y1,x2,y2].""", @@ -100,7 +100,7 @@ class PointExtractionResponse(BaseModel): class LineExtractionResponse(BaseModel): line_id: str = Field(default="", description="CDR line id") cog_id: str = Field(default="", description="Cog id") - px_bbox: List[Union[float, int]] = Field( + px_bbox: Optional[List[Union[float, int]]] = Field( default_factory=list, description="""The rough 2 point bounding box of the item. Format is expected to be [x1,y1,x2,y2].""", diff --git a/cdr_schemas/cdr_responses/legend_items.py b/cdr_schemas/cdr_responses/legend_items.py index 33b634a..18be38f 100644 --- a/cdr_schemas/cdr_responses/legend_items.py +++ b/cdr_schemas/cdr_responses/legend_items.py @@ -23,7 +23,7 @@ class LegendItemResponse(BaseModel): default="", description="If category of type polygon this can be filled in with pattern type", ) - px_bbox: List[Union[float, int]] = Field( + px_bbox: Optional[List[Union[float, int]]] = Field( default_factory=list, description="""The rough 2 point bounding box of the item. Format is expected to be [x1,y1,x2,y2].""", diff --git a/pyproject.toml b/pyproject.toml index fe50db2..cdc54f9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "cdr_schemas" -version = "0.3.0" +version = "0.3.1" description = "CDR Schemas" authors = [] readme = "README.md" From 9e3c5380eea5cd35d4c8f7e152488d57628d5069 Mon Sep 17 00:00:00 2001 From: marshHawk4 Date: Wed, 26 Jun 2024 13:03:38 -0400 Subject: [PATCH 4/8] Update optional (#39) * removed optional * test passing --- cdr_schemas/cdr_responses/area_extractions.py | 2 +- cdr_schemas/cdr_responses/features.py | 6 +++--- cdr_schemas/cdr_responses/legend_items.py | 2 +- cdr_schemas/features/point_features.py | 2 +- tests/test_point_extraction.py | 5 ++++- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cdr_schemas/cdr_responses/area_extractions.py b/cdr_schemas/cdr_responses/area_extractions.py index 878c0a2..e12054f 100644 --- a/cdr_schemas/cdr_responses/area_extractions.py +++ b/cdr_schemas/cdr_responses/area_extractions.py @@ -13,7 +13,7 @@ class AreaExtractionResponse(BaseModel): reference_id: Union[str, None] = Field( default=None, description="Legend id of older version of this legend item." ) - px_bbox: Optional[List[Union[float, int]]] = Field( + px_bbox: List[Union[float, int]] = Field( default_factory=list, description="""The rough 2 point bounding box of the item. Format is expected to be [x1,y1,x2,y2].""", diff --git a/cdr_schemas/cdr_responses/features.py b/cdr_schemas/cdr_responses/features.py index 08536d8..d36abe6 100644 --- a/cdr_schemas/cdr_responses/features.py +++ b/cdr_schemas/cdr_responses/features.py @@ -23,7 +23,7 @@ class ProjectedFeature(BaseModel): class PolygonExtractionResponse(BaseModel): polygon_id: str = Field(default="", description="CDR polygon id") cog_id: str = Field(default="", description="Cog id") - px_bbox: Optional[List[Union[float, int]]] = Field( + px_bbox: List[Union[float, int]] = Field( default_factory=list, description="""The rough 2 point bounding box of the item. Format is expected to be [x1,y1,x2,y2].""", @@ -57,7 +57,7 @@ class PolygonExtractionResponse(BaseModel): class PointExtractionResponse(BaseModel): point_id: str = Field(default="", description="CDR point id") cog_id: str = Field(default="", description="Cog id") - px_bbox: Optional[List[Union[float, int]]] = Field( + px_bbox: List[Union[float, int]] = Field( default_factory=list, description="""The rough 2 point bounding box of the item. Format is expected to be [x1,y1,x2,y2].""", @@ -100,7 +100,7 @@ class PointExtractionResponse(BaseModel): class LineExtractionResponse(BaseModel): line_id: str = Field(default="", description="CDR line id") cog_id: str = Field(default="", description="Cog id") - px_bbox: Optional[List[Union[float, int]]] = Field( + px_bbox: List[Union[float, int]] = Field( default_factory=list, description="""The rough 2 point bounding box of the item. Format is expected to be [x1,y1,x2,y2].""", diff --git a/cdr_schemas/cdr_responses/legend_items.py b/cdr_schemas/cdr_responses/legend_items.py index 18be38f..33b634a 100644 --- a/cdr_schemas/cdr_responses/legend_items.py +++ b/cdr_schemas/cdr_responses/legend_items.py @@ -23,7 +23,7 @@ class LegendItemResponse(BaseModel): default="", description="If category of type polygon this can be filled in with pattern type", ) - px_bbox: Optional[List[Union[float, int]]] = Field( + px_bbox: List[Union[float, int]] = Field( default_factory=list, description="""The rough 2 point bounding box of the item. Format is expected to be [x1,y1,x2,y2].""", diff --git a/cdr_schemas/features/point_features.py b/cdr_schemas/features/point_features.py index ce97ce1..52fd441 100644 --- a/cdr_schemas/features/point_features.py +++ b/cdr_schemas/features/point_features.py @@ -38,7 +38,7 @@ class PointProperties(BaseModel): ) # Point Properties - bbox: Optional[List[Union[float, int]]] = Field( + bbox: List[Union[float, int]] = Field( default=None, description="""The extacted 2 point bounding box of the point item. Format is expected to be [x1,y1,x2,y2] where the top left diff --git a/tests/test_point_extraction.py b/tests/test_point_extraction.py index 0c93188..d8d2431 100644 --- a/tests/test_point_extraction.py +++ b/tests/test_point_extraction.py @@ -27,7 +27,10 @@ def test_point_extraction_1(): { "id": "11", "geometry": {"coordinates": [23.33, 122]}, - "properties": {"model": "test", "model_version": "1"}, + "properties": { + "model": "test", + "model_version": "1", + "bbox":[]}, } ] }, From d828e4dd402b90383b50584da1e74fa9feadc984 Mon Sep 17 00:00:00 2001 From: marshHawk4 Date: Wed, 26 Jun 2024 13:09:12 -0400 Subject: [PATCH 5/8] bump version (#40) --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index cdc54f9..3518b0d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "cdr_schemas" -version = "0.3.1" +version = "0.3.2" description = "CDR Schemas" authors = [] readme = "README.md" From e0141eefe71c401a1e71a719a41a947aa0ed6471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B9=E3=82=B3=E3=83=83=E3=83=88?= Date: Wed, 26 Jun 2024 23:40:10 -0400 Subject: [PATCH 6/8] Mineral (#41) * mineral updates --- README.md | 880 ++++++++++++++++++++--------------------- cdr_schemas/mineral.py | 240 ++++++----- pyproject.toml | 2 +- 3 files changed, 559 insertions(+), 563 deletions(-) diff --git a/README.md b/README.md index d45a1f6..d35bc8b 100644 --- a/README.md +++ b/README.md @@ -77,15 +77,15 @@ classDiagram class Area_Extraction { type: GeomType = GeomType.Polygon - coordinates: list[list[list[float | int]]] - bbox: list[float | int] = list + coordinates: list[list[list[Union[float, int]]]] + bbox: list[Union[float, int]] = list category: AreaType text: str = '' reference_id: str = '' validated: bool = False model: str model_version: str - confidence: float | int | None = None + confidence: Union[float, int, NoneType] = None } class AreaType { @@ -117,50 +117,23 @@ classDiagram ```mermaid classDiagram - class GeoreferenceResults { - cog_id: str - georeference_results: list[GeoreferenceResult] = list - gcps: list[GroundControlPoint] = list - system: str - system_version: str - } - - class Geom_Point { - latitude: float | int | None - longitude: float | int | None - type: GeomType = GeomType.Point - } - - class GeoreferenceResult { - likely_CRSs: list[str] = list - map_area: Area_Extraction | None = None - projections: list[ProjectionResult] = list - } - - class Pixel_Point { - rows_from_top: float | int - columns_from_left: float | int - type: GeomType = GeomType.Point - } - - class GeomType { - <> - Point: str = 'Point' - LineString: str = 'LineString' - Polygon: str = 'Polygon' - } - class Area_Extraction { type: GeomType = GeomType.Polygon - coordinates: list[list[list[float | int]]] - bbox: list[float | int] = list + coordinates: list[list[list[Union[float, int]]]] + bbox: list[Union[float, int]] = list category: AreaType text: str = '' reference_id: str = '' validated: bool = False model: str model_version: str - confidence: float | int | None = None + confidence: Union[float, int, NoneType] = None + } + + class GeoreferenceResult { + likely_CRSs: list[str] = list + map_area: Optional[Area_Extraction] = None + projections: list[ProjectionResult] = list } class ProjectionResult { @@ -170,22 +143,49 @@ classDiagram validated: bool = False } + class Geom_Point { + latitude: Union[float, int, NoneType] + longitude: Union[float, int, NoneType] + type: GeomType = GeomType.Point + } + + class Pixel_Point { + rows_from_top: Union[float, int] + columns_from_left: Union[float, int] + type: GeomType = GeomType.Point + } + class GroundControlPoint { gcp_id: str map_geom: Geom_Point px_geom: Pixel_Point - confidence: float | int | None = None + confidence: Union[float, int, NoneType] = None model: str model_version: str crs: str } + class GeomType { + <> + Point: str = 'Point' + LineString: str = 'LineString' + Polygon: str = 'Polygon' + } + + class GeoreferenceResults { + cog_id: str + georeference_results: list[GeoreferenceResult] = list + gcps: list[GroundControlPoint] = list + system: str + system_version: str + } + Area_Extraction ..> GeomType Area_Extraction ..> AreaType Geom_Point ..> GeomType Pixel_Point ..> GeomType - GroundControlPoint ..> Pixel_Point GroundControlPoint ..> Geom_Point + GroundControlPoint ..> Pixel_Point GeoreferenceResult ..> Area_Extraction GeoreferenceResult ..> ProjectionResult GeoreferenceResults ..> GeoreferenceResult @@ -204,45 +204,45 @@ classDiagram ```mermaid classDiagram - class MapShapeTypes { + class MapColorSchemeTypes { <> - rectangular: str = 'rectangular' - non_rectangular: str = 'non_rectangular' + full_color: str = 'full_color' + monochrome: str = 'monochrome' + grayscale: str = 'grayscale' } class MapMetaData { title: str = '' - year: int | None = None + year: Optional[int] = None crs: str = '' authors: list[str] = list organization: str = '' - scale: int | None = None + scale: Optional[int] = None quadrangle_name: str = '' - map_shape: MapShapeTypes | None = None - map_color_scheme: MapColorSchemeTypes | None = None + map_shape: Optional[MapShapeTypes] = None + map_color_scheme: Optional[MapColorSchemeTypes] = None publisher: str = '' state: str = '' model: str model_version: str } - class MapColorSchemeTypes { + class MapShapeTypes { <> - full_color: str = 'full_color' - monochrome: str = 'monochrome' - grayscale: str = 'grayscale' + rectangular: str = 'rectangular' + non_rectangular: str = 'non_rectangular' } class CogMetaData { cog_id: str system: str system_version: str - multiple_maps: bool | None = None + multiple_maps: Optional[bool] = None map_metadata: list[MapMetaData] = list } - MapMetaData ..> MapShapeTypes MapMetaData ..> MapColorSchemeTypes + MapMetaData ..> MapShapeTypes CogMetaData ..> MapMetaData @@ -258,101 +258,101 @@ classDiagram ```mermaid classDiagram + class FeatureResults { + system: str + system_version: str + cog_id: str + line_feature_results: list[LineLegendAndFeaturesResult] = list + point_feature_results: list[PointLegendAndFeaturesResult] = list + polygon_feature_results: list[PolygonLegendAndFeaturesResult] = list + cog_area_extractions: list[Area_Extraction] = list + cog_metadata_extractions: list[CogMetaData] = list + } + + class Area_Extraction { + type: GeomType = GeomType.Polygon + coordinates: list[list[list[Union[float, int]]]] + bbox: list[Union[float, int]] = list + category: AreaType + text: str = '' + reference_id: str = '' + validated: bool = False + model: str + model_version: str + confidence: Union[float, int, NoneType] = None + } + class PolygonLegendAndFeaturesResult { id: str - legend_provenance: ModelProvenance | None = None + legend_provenance: Optional[ModelProvenance] = None label: str abbreviation: str = '' description: str = '' - legend_bbox: list[float | int] = list - legend_contour: list[list[float | int]] = list + legend_bbox: list[Union[float, int]] = list + legend_contour: list[list[Union[float, int]]] = list color: str = '' pattern: str = '' category: str = '' - map_unit: MapUnit | None = None + map_unit: Optional[MapUnit] = None reference_id: str = '' validated: bool = False crs: str = 'pixel' cdr_projection_id: str = '' - polygon_features: PolygonFeatureCollection | None = None - } - - class Area_Extraction { - type: GeomType = GeomType.Polygon - coordinates: list[list[list[float | int]]] - bbox: list[float | int] = list - category: AreaType - text: str = '' - reference_id: str = '' - validated: bool = False - model: str - model_version: str - confidence: float | int | None = None + polygon_features: Optional[PolygonFeatureCollection] = None } class CogMetaData { cog_id: str system: str system_version: str - multiple_maps: bool | None = None + multiple_maps: Optional[bool] = None map_metadata: list[MapMetaData] = list } - class LineLegendAndFeaturesResult { + class PointLegendAndFeaturesResult { id: str - legend_provenance: ModelProvenance | None = None - name: str = '' + legend_provenance: Optional[ModelProvenance] = None + name: str abbreviation: str = '' description: str = '' - legend_bbox: list[float | int] = list - legend_contour: list[list[float | int]] = list + legend_bbox: list[Union[float, int]] = list + legend_contour: list[list[Union[float, int]]] = list reference_id: str = '' validated: bool = False crs: str = 'pixel' cdr_projection_id: str = '' - line_features: LineFeatureCollection | None = None + point_features: Optional[PointFeatureCollection] = None } - class FeatureResults { - system: str - system_version: str - cog_id: str - line_feature_results: list[LineLegendAndFeaturesResult] = list - point_feature_results: list[PointLegendAndFeaturesResult] = list - polygon_feature_results: list[PolygonLegendAndFeaturesResult] = list - cog_area_extractions: list[Area_Extraction] = list - cog_metadata_extractions: list[CogMetaData] = list - } - - class PointLegendAndFeaturesResult { + class LineLegendAndFeaturesResult { id: str - legend_provenance: ModelProvenance | None = None - name: str + legend_provenance: Optional[ModelProvenance] = None + name: str = '' abbreviation: str = '' description: str = '' - legend_bbox: list[float | int] = list - legend_contour: list[list[float | int]] = list + legend_bbox: list[Union[float, int]] = list + legend_contour: list[list[Union[float, int]]] = list reference_id: str = '' validated: bool = False crs: str = 'pixel' cdr_projection_id: str = '' - point_features: PointFeatureCollection | None = None + line_features: Optional[LineFeatureCollection] = None } Area_Extraction ..> GeomType Area_Extraction ..> AreaType LineLegendAndFeaturesResult ..> LineFeatureCollection LineLegendAndFeaturesResult ..> ModelProvenance - PointLegendAndFeaturesResult ..> PointFeatureCollection PointLegendAndFeaturesResult ..> ModelProvenance + PointLegendAndFeaturesResult ..> PointFeatureCollection PolygonLegendAndFeaturesResult ..> ModelProvenance PolygonLegendAndFeaturesResult ..> MapUnit PolygonLegendAndFeaturesResult ..> PolygonFeatureCollection CogMetaData ..> MapMetaData FeatureResults ..> Area_Extraction - FeatureResults ..> CogMetaData FeatureResults ..> PolygonLegendAndFeaturesResult FeatureResults ..> LineLegendAndFeaturesResult + FeatureResults ..> CogMetaData FeatureResults ..> PointLegendAndFeaturesResult @@ -368,76 +368,76 @@ classDiagram ```mermaid classDiagram - class PointProperties { - model: str - model_version: str - confidence: float | int | None = None - bbox: list[float | int] | None = None - dip: int | None = None - dip_direction: int | None = None - reference_id: str = '' - validated: bool = False - } - class PointFeatureCollection { type: GeoJsonType = GeoJsonType.FeatureCollection features: list[PointFeature] = list } - class PointFeature { - type: GeoJsonType = GeoJsonType.Feature - id: str - geometry: Point - properties: PointProperties - } - - class GeomType { + class GeoJsonType { <> - Point: str = 'Point' - LineString: str = 'LineString' - Polygon: str = 'Polygon' + Feature: str = 'Feature' + FeatureCollection: str = 'FeatureCollection' } class Point { - coordinates: list[float | int] + coordinates: list[Union[float, int]] type: GeomType = GeomType.Point } - class GeoJsonType { + class GeomType { <> - Feature: str = 'Feature' - FeatureCollection: str = 'FeatureCollection' + Point: str = 'Point' + LineString: str = 'LineString' + Polygon: str = 'Polygon' } class ModelProvenance { model: str model_version: str - confidence: float | int | None = None + confidence: Union[float, int, NoneType] = None + } + + class PointFeature { + type: GeoJsonType = GeoJsonType.Feature + id: str + geometry: Point + properties: PointProperties } class PointLegendAndFeaturesResult { id: str - legend_provenance: ModelProvenance | None = None + legend_provenance: Optional[ModelProvenance] = None name: str abbreviation: str = '' description: str = '' - legend_bbox: list[float | int] = list - legend_contour: list[list[float | int]] = list + legend_bbox: list[Union[float, int]] = list + legend_contour: list[list[Union[float, int]]] = list reference_id: str = '' validated: bool = False crs: str = 'pixel' cdr_projection_id: str = '' - point_features: PointFeatureCollection | None = None + point_features: Optional[PointFeatureCollection] = None + } + + class PointProperties { + model: str + model_version: str + confidence: Union[float, int, NoneType] = None + bbox: list[Union[float, int]] = None + dip: Optional[int] = None + dip_direction: Optional[int] = None + reference_id: str = '' + validated: bool = False } Point ..> GeomType - PointFeature ..> PointProperties PointFeature ..> Point PointFeature ..> GeoJsonType + PointFeature ..> PointProperties PointFeatureCollection ..> PointFeature PointFeatureCollection ..> GeoJsonType - PointLegendAndFeaturesResult ..> PointFeatureCollection PointLegendAndFeaturesResult ..> ModelProvenance + PointLegendAndFeaturesResult ..> PointFeatureCollection ``` @@ -459,62 +459,62 @@ classDiagram properties: LineProperty } - class Line { - coordinates: list[list[float | int]] - type: GeomType = GeomType.LineString - } - - class GeomType { - <> - Point: str = 'Point' - LineString: str = 'LineString' - Polygon: str = 'Polygon' - } - - class DashType { - <> - solid: str = 'solid' - dash: str = 'dash' - dotted: str = 'dotted' - } - class GeoJsonType { <> Feature: str = 'Feature' FeatureCollection: str = 'FeatureCollection' } - class LineFeatureCollection { - type: GeoJsonType = GeoJsonType.FeatureCollection - features: list[LineFeature] = list - } - class LineLegendAndFeaturesResult { id: str - legend_provenance: ModelProvenance | None = None + legend_provenance: Optional[ModelProvenance] = None name: str = '' abbreviation: str = '' description: str = '' - legend_bbox: list[float | int] = list - legend_contour: list[list[float | int]] = list + legend_bbox: list[Union[float, int]] = list + legend_contour: list[list[Union[float, int]]] = list reference_id: str = '' validated: bool = False crs: str = 'pixel' cdr_projection_id: str = '' - line_features: LineFeatureCollection | None = None + line_features: Optional[LineFeatureCollection] = None + } + + class LineFeatureCollection { + type: GeoJsonType = GeoJsonType.FeatureCollection + features: list[LineFeature] = list + } + + class GeomType { + <> + Point: str = 'Point' + LineString: str = 'LineString' + Polygon: str = 'Polygon' } class ModelProvenance { model: str model_version: str - confidence: float | int | None = None + confidence: Union[float, int, NoneType] = None + } + + class DashType { + <> + solid: str = 'solid' + dash: str = 'dash' + dotted: str = 'dotted' + } + + class Line { + coordinates: list[list[Union[float, int]]] + type: GeomType = GeomType.LineString } class LineProperty { model: str model_version: str - confidence: float | int | None = None - dash_pattern: DashType | None = None + confidence: Union[float, int, NoneType] = None + dash_pattern: Optional[DashType] = None symbol: str = '' reference_id: str = '' validated: bool = False @@ -543,73 +543,65 @@ classDiagram ```mermaid classDiagram - class PolygonFeature { - type: GeoJsonType = GeoJsonType.Feature - id: str - geometry: Polygon - properties: PolygonProperty - } - - class Polygon { - coordinates: list[list[list[float | int]]] - type: GeomType = GeomType.Polygon - } - - class GeomType { - <> - Point: str = 'Point' - LineString: str = 'LineString' - Polygon: str = 'Polygon' - } - - class PolygonProperty { - model: str - model_version: str - reference_id: str = '' - validated: bool = False - confidence: float | int | None = None - } - - class GeoJsonType { - <> - Feature: str = 'Feature' - FeatureCollection: str = 'FeatureCollection' + class MapUnit { + age_text: str = '' + b_age: Optional[float] = None + b_interval: str = '' + lithology: str = '' + name: str = '' + t_age: Optional[float] = None + t_interval: str = '' + comments: str = '' } class PolygonLegendAndFeaturesResult { id: str - legend_provenance: ModelProvenance | None = None + legend_provenance: Optional[ModelProvenance] = None label: str abbreviation: str = '' description: str = '' - legend_bbox: list[float | int] = list - legend_contour: list[list[float | int]] = list + legend_bbox: list[Union[float, int]] = list + legend_contour: list[list[Union[float, int]]] = list color: str = '' pattern: str = '' category: str = '' - map_unit: MapUnit | None = None + map_unit: Optional[MapUnit] = None reference_id: str = '' validated: bool = False crs: str = 'pixel' cdr_projection_id: str = '' - polygon_features: PolygonFeatureCollection | None = None + polygon_features: Optional[PolygonFeatureCollection] = None + } + + class GeoJsonType { + <> + Feature: str = 'Feature' + FeatureCollection: str = 'FeatureCollection' + } + + class PolygonFeature { + type: GeoJsonType = GeoJsonType.Feature + id: str + geometry: Polygon + properties: PolygonProperty + } + + class GeomType { + <> + Point: str = 'Point' + LineString: str = 'LineString' + Polygon: str = 'Polygon' } class ModelProvenance { model: str model_version: str - confidence: float | int | None = None + confidence: Union[float, int, NoneType] = None } - class MapUnit { - age_text: str = '' - b_age: float | None = None - b_interval: str = '' - lithology: str = '' - name: str = '' - t_age: float | None = None - t_interval: str = '' - comments: str = '' + class Polygon { + coordinates: list[list[list[Union[float, int]]]] + type: GeomType = GeomType.Polygon } class PolygonFeatureCollection { @@ -617,12 +609,20 @@ classDiagram features: list[PolygonFeature] = list } + class PolygonProperty { + model: str + model_version: str + reference_id: str = '' + validated: bool = False + confidence: Union[float, int, NoneType] = None + } + Polygon ..> GeomType PolygonFeature ..> Polygon PolygonFeature ..> PolygonProperty PolygonFeature ..> GeoJsonType - PolygonFeatureCollection ..> PolygonFeature PolygonFeatureCollection ..> GeoJsonType + PolygonFeatureCollection ..> PolygonFeature PolygonLegendAndFeaturesResult ..> ModelProvenance PolygonLegendAndFeaturesResult ..> MapUnit PolygonLegendAndFeaturesResult ..> PolygonFeatureCollection @@ -640,45 +640,45 @@ classDiagram ```mermaid classDiagram - class MapShapeTypes { + class MapColorSchemeTypes { <> - rectangular: str = 'rectangular' - non_rectangular: str = 'non_rectangular' + full_color: str = 'full_color' + monochrome: str = 'monochrome' + grayscale: str = 'grayscale' } class MapMetaData { title: str = '' - year: int | None = None + year: Optional[int] = None crs: str = '' authors: list[str] = list organization: str = '' - scale: int | None = None + scale: Optional[int] = None quadrangle_name: str = '' - map_shape: MapShapeTypes | None = None - map_color_scheme: MapColorSchemeTypes | None = None + map_shape: Optional[MapShapeTypes] = None + map_color_scheme: Optional[MapColorSchemeTypes] = None publisher: str = '' state: str = '' model: str model_version: str } - class MapColorSchemeTypes { + class MapShapeTypes { <> - full_color: str = 'full_color' - monochrome: str = 'monochrome' - grayscale: str = 'grayscale' + rectangular: str = 'rectangular' + non_rectangular: str = 'non_rectangular' } class CogMetaData { cog_id: str system: str system_version: str - multiple_maps: bool | None = None + multiple_maps: Optional[bool] = None map_metadata: list[MapMetaData] = list } - MapMetaData ..> MapShapeTypes MapMetaData ..> MapColorSchemeTypes + MapMetaData ..> MapShapeTypes CogMetaData ..> MapMetaData @@ -698,43 +698,43 @@ classDiagram doi: str = '' authors: list[str] = list journal: str = '' - year: int | None = None - month: int | None = None - volume: int | None = None + year: Optional[int] = None + month: Optional[int] = None + volume: Optional[int] = None issue: str = '' description: str = '' publisher: str = '' } - class DocumentProvenance { - external_system_name: str - external_system_id: str = '' - external_system_url: str = '' - } - class UploadDocument { title: str is_open: bool = True provenance: list[DocumentProvenance] = list - metadata: DocumentMetaData | None = None + metadata: Optional[DocumentMetaData] = None system: str system_version: str } class DocumentExtraction { - id: str | None = None + id: UnionType[str, NoneType] = None document_id: str = None extraction_type: str extraction_label: str - score: float | None = None - bbox: tuple[float, float, float, float] | None = None - page_num: int | None = None - external_link: str | None = None - data: dict[] | None = None + score: UnionType[float, NoneType] = None + bbox: UnionType[tuple[float, float, float, float], NoneType] = None + page_num: UnionType[int, NoneType] = None + external_link: UnionType[str, NoneType] = None + data: Optional[dict[]] = None system: str system_version: str } + class DocumentProvenance { + external_system_name: str + external_system_id: str = '' + external_system_url: str = '' + } + class Document { id: str title: str @@ -742,7 +742,7 @@ classDiagram pages: int size: int provenance: list[DocumentProvenance] = list - metadata: DocumentMetaData | None = None + metadata: Optional[DocumentMetaData] = None system: str system_version: str } @@ -765,99 +765,107 @@ classDiagram ```mermaid classDiagram - class PageInfo { - page: int - bounding_box: BoundingBox | None + class MineralInventory { + contained_metal: Optional[float] = None + commodity: str = '' + commodity_observed_name: str = '' + ore_unit: str = '' + ore_value: Optional[float] = None + grade_unit: str = '' + grade_value: Optional[float] = None + cutoff_grade_unit: str = '' + cutoff_grade_value: Optional[float] = None + material_form: Optional[float] = None + material_form_unit: str = '' + material_form_conversion: Optional[float] = None + confidence: Optional[Confidence] = None + categories: list[MineralInventoryCategory] = list + documents: list[DocumentReference] = list + records: list[RecordReference] = list + date: Optional[datetime] = None + zone: str = '' } - class Document { - id: str - title: str - is_open: bool - pages: int - size: int - provenance: list[DocumentProvenance] = list - metadata: DocumentMetaData | None = None - system: str - system_version: str + class DepositTypeCandidate { + observed_name: str = '' + name: str + confidence: Union[float, int, NoneType] = None + source: str } - class LocationInfo { - location: Geometry - crs: str - country: str = '' - state_or_province: str | None + class RecordReference { + record_id: str = '' + source: str = '' + uri: str = '' } class EvidenceLayer { - name: str + name: str = '' relevance_score: float } - class Commodity { - name: str + class MappableCriteria { + criteria: str + theoretical: str = '' + potential_dataset: list[EvidenceLayer] = list + supporting_references: list[DocumentReference] } - class Geometry { - <> - Point: str = 'Point' - Polygon: str = 'Polygon' + class DocumentReference { + cdr_id: str + page: Optional[int] = None + x_min: Optional[float] = None + x_max: Optional[float] = None + y_min: Optional[float] = None + y_max: Optional[float] = None } - class Grade { - grade_unit: str - grade_value: float + class DepositType { + name: str + environment: str + group: str } - class DepositTypeCandidate { - observed_name: str - normalized_uri: DepositType - confidence: float | int | None + class MineralInventoryCategory { + category: str + confidence: Union[float, int, NoneType] = None source: str } - class Ore { - ore_unit: str - ore_value: float - } - - class BoundingBox { - x_min: float - x_max: float - y_min: float - y_max: float - } - - class MineralInventory { - commodity: Commodity - observed_commodity: str = '' - category: ResourceReserveCategory | None - ore: Ore | None - grade: Grade | None - cutoff_grade: Grade | None - contained_metal: float | None - reference: Reference - date: datetime | None - zone: str = '' - } - - class MappableCriteria { - criteria: str - theoretical: str = '' - potential_dataset: list[EvidenceLayer] = list - supporting_references: list[Reference] + class MineralSite { + id: str + source_id: str = '' + record_id: str = '' + name: str = '' + site_rank: str = '' + site_type: str = '' + country: list[str] = list + province: list[str] = list + location: Optional[GeoLocationInfo] = None + mineral_inventory: list[MineralInventory] = list + deposit_type_candidate: list[DepositTypeCandidate] = list } class MineralSystem { - deposit_type: list[DepositType] - source: list[MappableCriteria] - pathway: list[MappableCriteria] + deposit_type: list[str] = list + source: list[MappableCriteria] = list + pathway: list[MappableCriteria] = list trap: list[MappableCriteria] = list preservation: list[MappableCriteria] = list energy: list[MappableCriteria] = list outflow: list[MappableCriteria] = list } + class Confidence { + confidence: Union[float, int, NoneType] = None + source: str + } + + class GeoLocationInfo { + crs: str + geom: str + } + class GeologyInfo { age: str = '' unit_name: str = '' @@ -868,57 +876,17 @@ classDiagram comments: str = '' } - class DepositType { - name: str - environment: str - group: str - } - - class MineralSite { - source_id: str - record_id: str - name: str = '' - mineral_inventory: list[MineralInventory] - location_info: LocationInfo - geology_info: GeologyInfo | None - deposit_type_candidate: list[DepositTypeCandidate] - } - - class Reference { - document: Document - page_info: list[PageInfo] = list - } - - class ResourceReserveCategory { - <> - INFERRED: str = 'Inferred Mineral Resource' - INDICATED: str = 'Indicated Mineral Resource' - MEASURED: str = 'Measured Mineral Resource' - PROBABLE: str = 'Probable Mineral Reserve' - PROVEN: str = 'Proven Mineral Reserve' - } - - Document ..> DocumentMetaData - Document ..> DocumentProvenance - DepositTypeCandidate ..> DepositType - PageInfo ..> BoundingBox - Reference ..> PageInfo - Reference ..> Document + MappableCriteria ..> DocumentReference MappableCriteria ..> EvidenceLayer - MappableCriteria ..> Reference - MineralSystem ..> DepositType MineralSystem ..> MappableCriteria - MineralInventory ..> Reference - MineralInventory ..> Ore - MineralInventory ..> Grade - MineralInventory ..> Commodity - MineralInventory ..> ResourceReserveCategory + MineralInventory ..> MineralInventoryCategory + MineralInventory ..> Confidence MineralInventory ..> datetime - LocationInfo ..> Geometry - MineralSite ..> GeologyInfo - MineralSite ..> DepositTypeCandidate + MineralInventory ..> DocumentReference + MineralInventory ..> RecordReference MineralSite ..> MineralInventory - MineralSite ..> LocationInfo + MineralSite ..> GeoLocationInfo + MineralSite ..> DepositTypeCandidate ``` @@ -933,12 +901,15 @@ classDiagram ```mermaid classDiagram - class GeoreferenceResults { - cog_id: str - georeference_results: list[GeoreferenceResult] = list - gcps: list[GroundControlPoint] = list + class FeatureResults { system: str system_version: str + cog_id: str + line_feature_results: list[LineLegendAndFeaturesResult] = list + point_feature_results: list[PointLegendAndFeaturesResult] = list + polygon_feature_results: list[PolygonLegendAndFeaturesResult] = list + cog_area_extractions: list[Area_Extraction] = list + cog_metadata_extractions: list[CogMetaData] = list } class MapResults { @@ -947,26 +918,23 @@ classDiagram extraction_results: list[FeatureResults] = list } - class FeatureResults { + class GeoreferenceResults { + cog_id: str + georeference_results: list[GeoreferenceResult] = list + gcps: list[GroundControlPoint] = list system: str system_version: str - cog_id: str - line_feature_results: list[LineLegendAndFeaturesResult] = list - point_feature_results: list[PointLegendAndFeaturesResult] = list - polygon_feature_results: list[PolygonLegendAndFeaturesResult] = list - cog_area_extractions: list[Area_Extraction] = list - cog_metadata_extractions: list[CogMetaData] = list } FeatureResults ..> Area_Extraction - FeatureResults ..> CogMetaData FeatureResults ..> PolygonLegendAndFeaturesResult FeatureResults ..> LineLegendAndFeaturesResult + FeatureResults ..> CogMetaData FeatureResults ..> PointLegendAndFeaturesResult GeoreferenceResults ..> GeoreferenceResult GeoreferenceResults ..> GroundControlPoint - MapResults ..> GeoreferenceResults MapResults ..> FeatureResults + MapResults ..> GeoreferenceResults ``` @@ -1016,30 +984,6 @@ classDiagram SHP: str = 'shp' } - class InterpolationType { - <> - LINEAR: str = 'linear' - CUBIC: str = 'cubic' - NEAREST: str = 'nearest' - NONE: str = 'none' - } - - class StackMetaData { - title: str | None - year: int | None - crs: str | None - authors: list[str] | None - organization: str | None - scale: int | None - evidence_layers: list[ProcessedDataLayer] - } - - class LayerDataType { - <> - CONTINUOUS: str = 'continuous' - BINARY: str = 'binary' - } - class ScalingType { <> MINMAX: str = 'minmax' @@ -1048,7 +992,7 @@ classDiagram } class ProcessedDataLayer { - title: str | None + title: Optional[str] resampling_method: InterpolationType scaling_method: ScalingType normalization_method: str @@ -1062,25 +1006,49 @@ classDiagram } class DataSource { - DOI: str | None - authors: list[str] | None - publication_date: str | None - category: LayerCategory | str | None - subcategory: str | None - description: str | None - derivative_ops: str | None + DOI: Optional[str] + authors: Optional[list[str]] + publication_date: Optional[str] + category: Union[LayerCategory, str, NoneType] + subcategory: Optional[str] + description: Optional[str] + derivative_ops: Optional[str] type: LayerDataType - resolution: tuple | None + resolution: Optional[tuple] format: DataFormat - download_url: str | None + download_url: Optional[str] + } + + class LayerDataType { + <> + CONTINUOUS: str = 'continuous' + BINARY: str = 'binary' + } + + class InterpolationType { + <> + LINEAR: str = 'linear' + CUBIC: str = 'cubic' + NEAREST: str = 'nearest' + NONE: str = 'none' + } + + class StackMetaData { + title: Optional[str] + year: Optional[int] + crs: Optional[str] + authors: Optional[list[str]] + organization: Optional[str] + scale: Optional[int] + evidence_layers: list[ProcessedDataLayer] } - DataSource ..> LayerDataType - DataSource ..> DataFormat DataSource ..> tuple + DataSource ..> DataFormat DataSource ..> LayerCategory - ProcessedDataLayer ..> ScalingType + DataSource ..> LayerDataType ProcessedDataLayer ..> InterpolationType + ProcessedDataLayer ..> ScalingType StackMetaData ..> ProcessedDataLayer @@ -1096,43 +1064,46 @@ classDiagram ```mermaid classDiagram - class CMAModel { - title: str | None - date: int | None - authors: list[str] | None - organization: str | None - cma_model_type: NeuralNetModel | SOMModel - training_data: StackMetaData + class SOMTrainConfig { + dimensions_x: int + dimensions_y: int + num_epochs: int + num_initializations: int + neighborhood_function: NeighborhoodFunction + som_type: SOMType + neighborhood_decay: NeighborhoodDecay + learning_rate_decay: LearningRateDecay + initial_learning_rate: float + final_learning_rate: float + som_initialization: SOMInitialization + som_grid: SOMGrid } - class SOMGrid { + class LearningRateDecay { <> - HEXAGONAL: str = 'hexagonal' - RECTANGULAR: str = 'rectangular' - } - - class NeuralNetModel { - train_config: NeuralNetTrainConfig + LINEAR: str = 'linear' + EXPONENTIAL: str = 'exponential' } - class Accelerator { + class SOMType { <> - CPU: str = 'cpu' - GPU: str = 'gpu' + TOROID: str = 'toroid' + SHEET: str = 'sheet' } - class StackMetaData { - title: str | None - year: int | None - crs: str | None - authors: list[str] | None - organization: str | None - scale: int | None - evidence_layers: list[ProcessedDataLayer] + class SOMInitialization { + <> + RANDOM: str = 'random' + PCA: str = 'pca' } - class SOMModel { - train_config: SOMTrainConfig + class CMAModel { + title: Optional[str] + date: Optional[int] + authors: Optional[list[str]] + organization: Optional[str] + cma_model_type: Union[NeuralNetModel, SOMModel] + training_data: StackMetaData } class NeighborhoodDecay { @@ -1141,37 +1112,34 @@ classDiagram EXPONENTIAL: str = 'exponential' } - class LearningRateDecay { - <> - LINEAR: str = 'linear' - EXPONENTIAL: str = 'exponential' + class SOMModel { + train_config: SOMTrainConfig } - class SOMTrainConfig { - dimensions_x: int - dimensions_y: int - num_epochs: int - num_initializations: int - neighborhood_function: NeighborhoodFunction - som_type: SOMType - neighborhood_decay: NeighborhoodDecay - learning_rate_decay: LearningRateDecay - initial_learning_rate: float - final_learning_rate: float - som_initialization: SOMInitialization - som_grid: SOMGrid + class Accelerator { + <> + CPU: str = 'cpu' + GPU: str = 'gpu' } - class SOMInitialization { + class SOMGrid { <> - RANDOM: str = 'random' - PCA: str = 'pca' + HEXAGONAL: str = 'hexagonal' + RECTANGULAR: str = 'rectangular' } - class SOMType { - <> - TOROID: str = 'toroid' - SHEET: str = 'sheet' + class StackMetaData { + title: Optional[str] + year: Optional[int] + crs: Optional[str] + authors: Optional[list[str]] + organization: Optional[str] + scale: Optional[int] + evidence_layers: list[ProcessedDataLayer] + } + + class NeuralNetModel { + train_config: NeuralNetTrainConfig } class NeighborhoodFunction { @@ -1191,17 +1159,17 @@ classDiagram StackMetaData ..> ProcessedDataLayer NeuralNetTrainConfig ..> Accelerator - SOMTrainConfig ..> SOMInitialization SOMTrainConfig ..> SOMGrid + SOMTrainConfig ..> LearningRateDecay SOMTrainConfig ..> SOMType + SOMTrainConfig ..> SOMInitialization SOMTrainConfig ..> NeighborhoodFunction SOMTrainConfig ..> NeighborhoodDecay - SOMTrainConfig ..> LearningRateDecay NeuralNetModel ..> NeuralNetTrainConfig SOMModel ..> SOMTrainConfig - CMAModel ..> StackMetaData - CMAModel ..> NeuralNetModel CMAModel ..> SOMModel + CMAModel ..> NeuralNetModel + CMAModel ..> StackMetaData ``` diff --git a/cdr_schemas/mineral.py b/cdr_schemas/mineral.py index dbccc5d..4bdbd2d 100644 --- a/cdr_schemas/mineral.py +++ b/cdr_schemas/mineral.py @@ -1,40 +1,58 @@ from datetime import datetime -from enum import Enum from typing import List, Optional, Union from pydantic import BaseModel, Field -from cdr_schemas.document import Document +class DocumentReference(BaseModel): + cdr_id: str + page: Optional[int] = Field(default=None) + x_min: Optional[float] = Field(default=None) + x_max: Optional[float] = Field(default=None) + y_min: Optional[float] = Field(default=None) + y_max: Optional[float] = Field(default=None) -class Geometry(Enum): - Point = "Point" - Polygon = "Polygon" +class EvidenceLayer(BaseModel): + name: str = Field(default="") + relevance_score: float -class ResourceReserveCategory(Enum): - INFERRED = "Inferred Mineral Resource" - INDICATED = "Indicated Mineral Resource" - MEASURED = "Measured Mineral Resource" - PROBABLE = "Probable Mineral Reserve" - PROVEN = "Proven Mineral Reserve" + +class MappableCriteria(BaseModel): + criteria: str + theoretical: str = Field(default="") + potential_dataset: list[EvidenceLayer] = Field( + default_factory=list, description="List of evidence layers" + ) + supporting_references: list[DocumentReference] + + +class MineralSystem(BaseModel): + deposit_type: list[str] = Field(default_factory=list) + source: list[MappableCriteria] = Field(default_factory=list) + pathway: list[MappableCriteria] = Field(default_factory=list) + trap: list[MappableCriteria] = Field( + default_factory=list, description="Mappable Criteria: trap" + ) + preservation: list[MappableCriteria] = Field( + default_factory=list, description="Mappable Criteria: Preservation" + ) + energy: list[MappableCriteria] = Field( + default_factory=list, description="Mappable Criteria: Energy" + ) + outflow: list[MappableCriteria] = Field( + default_factory=list, description="Mappable Criteria: outflow" + ) class GeologyInfo(BaseModel): age: str = Field(default="", description="Age of the geologic unit or event") unit_name: str = Field(default="", description="Name of the geologic unit") - description: str = "" + description: str = Field(default="") lithology: List[str] = Field(default_factory=list, description="Lithology") process: List[str] = Field(default_factory=list, description="Process") environment: List[str] = Field(default_factory=list, description="environment") - comments: str = "" - - -class Ore(BaseModel): - ore_unit: str = Field( - description="The unit in which ore quantity is measured, eg, metric tonnes" - ) - ore_value: float = Field(description="The value of ore quantity") + comments: str = Field(default="") class DepositType(BaseModel): @@ -45,104 +63,111 @@ class DepositType(BaseModel): class DepositTypeCandidate(BaseModel): observed_name: str = Field( - description="Source dataset that the site info is retrieved from. e.g., MRDS" - ) - normalized_uri: DepositType = Field( - description="The deposit type of an inventory item" + default="", + description="Source dataset that the site info is retrieved from. e.g., MRDS", ) + + name: str = Field(description="Deposit type name") + confidence: Optional[Union[float, int]] = Field( - description="Score deposit type of an inventory item" + default=None, description="Score deposit type of an inventory item" ) source: str = Field( description="Source of the classification (automated model version / SME / etc...)" ) -class BoundingBox(BaseModel): - x_min: float - x_max: float - y_min: float - y_max: float +class RecordReference(BaseModel): + record_id: str = Field(default="", description="id in source") + source: str = Field(default="", description="Source information") + uri: str = Field(default="", description="uri of source") -class PageInfo(BaseModel): - page: int - bounding_box: Optional[BoundingBox] = Field( - description="Coordinates of the document where reference is found" +class MineralInventoryCategory(BaseModel): + category: str = Field(description="category name") + confidence: Optional[Union[float, int]] = Field( + default=None, + ) + source: str = Field( + description="Source of the classification (automated model version / SME / etc...)" ) -class Reference(BaseModel): - document: Document - page_info: List[PageInfo] = Field( - default_factory=list, - description="List of pages and their respective bounding boxes where the reference is found", +class GeoLocationInfo(BaseModel): + crs: str = Field( + description="The Coordinate Reference System (CRS) of the location" ) - -class EvidenceLayer(BaseModel): - name: str - relevance_score: float + geom: str = Field( + description="Type: Polygon or Point, value indicates the geolocation of the site" + ) -class MappableCriteria(BaseModel): - criteria: str - theoretical: str = "" - potential_dataset: list[EvidenceLayer] = Field( - default_factory=list, description="List of evidence layers" +class Confidence(BaseModel): + confidence: Optional[Union[float, int]] = Field(default=None) + source: str = Field( + description="Source of the classification (automated model version / SME / etc...)" ) - supporting_references: list[Reference] -class MineralSystem(BaseModel): - deposit_type: list[DepositType] - source: list[MappableCriteria] - pathway: list[MappableCriteria] - trap: list[MappableCriteria] = Field( - default_factory=list, description="Mappable Criteria: trap" +class MineralInventory(BaseModel): + contained_metal: Optional[float] = Field( + default=None, + description="The quantity of a contained metal in an inventory item", ) - preservation: list[MappableCriteria] = Field( - default_factory=list, description="Mappable Criteria: Preservation" + commodity: str = Field(default="", description="The commodity of an inventory item") + commodity_observed_name: str = Field( + default="", + description="The observed commodity in the source data (textual format)", ) - energy: list[MappableCriteria] = Field( - default_factory=list, description="Mappable Criteria: Energy" + + ore_unit: str = Field( + default="", + description="The unit in which ore quantity is measured, eg, metric tonnes", ) - outflow: list[MappableCriteria] = Field( - default_factory=list, description="Mappable Criteria: outflow" + ore_value: Optional[float] = Field( + default=None, description="The value of ore quantity" ) - -class Commodity(BaseModel): - name: str - - -class Grade(BaseModel): grade_unit: str = Field( - description="The unit in which grade is measured, eg, percent" + default="", description="The unit in which grade is measured, eg, percent" ) - grade_value: float = Field(description="The value of grade") + grade_value: Optional[float] = Field(default=None, description="The value of grade") - -class MineralInventory(BaseModel): - commodity: Commodity = Field(description="The commodity of an inventory item") - observed_commodity: str = Field( - default="", - description="The observed commodity in the source data (textual format)", + cutoff_grade_unit: str = Field( + default="", description="The unit in which grade is measured, eg, percent" ) - category: Optional[ResourceReserveCategory] = Field( - description="The category of an inventory item" + cutoff_grade_value: Optional[float] = Field(default=None) + + material_form: Optional[float] = Field(default=None) + material_form_unit: str = Field(default="") + material_form_conversion: Optional[float] = Field(default=None) + + confidence: Optional[Confidence] = Field(default=None) + + categories: List[MineralInventoryCategory] = Field( + default_factory=list, + description=""" + A list of categories + """, ) - ore: Optional[Ore] = Field(description="The ore of an inventory item") - grade: Optional[Grade] = Field(description="The grade of an inventory item") - cutoff_grade: Optional[Grade] = Field( - description="The cutoff grade of the observed inventory item" + + documents: List[DocumentReference] = Field( + default_factory=list, + description=""" + A list of document references + """, ) - contained_metal: Optional[float] = Field( - description="The quantity of a contained metal in an inventory item" + + records: List[RecordReference] = Field( + default_factory=list, + description=""" + A list of records references from databases or other sources + """, ) - reference: Reference = Field(description="The reference of an inventory item") + date: Optional[datetime] = Field( - description="When in the point of time mineral inventory valid" + default=None, description="When in the point of time mineral inventory valid" ) zone: str = Field( default="", @@ -150,30 +175,33 @@ class MineralInventory(BaseModel): ) -class LocationInfo(BaseModel): - location: Geometry = Field( - description="Type: Polygon or Point, value indicates the geolocation of the site" - ) - crs: str = Field( - description="The Coordinate Reference System (CRS) of the location" - ) - country: str = Field( - default="", description="Country that the mine site resides in" - ) - state_or_province: Optional[str] = Field( - description="State or province that the mine site resides in" - ) - - class MineralSite(BaseModel): + id: str = Field(description="Mineral Site Id") source_id: str = Field( - description="Source dataset that the site info is retrieved from. e.g., MRDS" + default="", + description="Source dataset that the site info is retrieved from. e.g., MRDS", ) record_id: str = Field( - description="Unique ID of the record that the info is retrieved from e.g., 10022920" + default="", + description="Unique ID of the record that the info is retrieved from e.g., 10022920", ) name: str = Field(default="", description="Name of the mine, e.g., Tungsten Jim") - mineral_inventory: list[MineralInventory] - location_info: LocationInfo - geology_info: Optional[GeologyInfo] - deposit_type_candidate: list[DepositTypeCandidate] + + site_rank: str = Field(default="") + site_type: str = Field(default="") + country: List[str] = Field(default_factory=list) + province: List[str] = Field(default_factory=list) + location: Optional[GeoLocationInfo] = Field(default=None) + mineral_inventory: List[MineralInventory] = Field( + default_factory=list, + description=""" + A list of mineral inventories + """, + ) + + deposit_type_candidate: List[DepositTypeCandidate] = Field( + default_factory=list, + description=""" + A list of deposit types candidates + """, + ) diff --git a/pyproject.toml b/pyproject.toml index 3518b0d..4cbc15a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "cdr_schemas" -version = "0.3.2" +version = "0.3.3" description = "CDR Schemas" authors = [] readme = "README.md" From 429fad62da81e63f499d9b828089872db7f4ce94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B9=E3=82=B3=E3=83=83=E3=83=88?= Date: Tue, 2 Jul 2024 17:40:03 -0400 Subject: [PATCH 7/8] mineral inventory date fix (#42) * switch date to string --- cdr_schemas/mineral.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cdr_schemas/mineral.py b/cdr_schemas/mineral.py index 4bdbd2d..75f842f 100644 --- a/cdr_schemas/mineral.py +++ b/cdr_schemas/mineral.py @@ -1,4 +1,3 @@ -from datetime import datetime from typing import List, Optional, Union from pydantic import BaseModel, Field @@ -166,8 +165,8 @@ class MineralInventory(BaseModel): """, ) - date: Optional[datetime] = Field( - default=None, description="When in the point of time mineral inventory valid" + date: str = Field( + default="", description="When in the point of time mineral inventory valid" ) zone: str = Field( default="", From 1b66dfa5325a9913a4fb71bd05f232d5a161fcf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=B9=E3=82=B3=E3=83=83=E3=83=88?= Date: Wed, 3 Jul 2024 10:27:18 -0400 Subject: [PATCH 8/8] add id to deposit type (#43) --- cdr_schemas/mineral.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cdr_schemas/mineral.py b/cdr_schemas/mineral.py index 75f842f..ab8e5d4 100644 --- a/cdr_schemas/mineral.py +++ b/cdr_schemas/mineral.py @@ -55,6 +55,7 @@ class GeologyInfo(BaseModel): class DepositType(BaseModel): + id: Optional[str] = Field(default=None, description="Deposit type id") name: str = Field(description="Deposit type name") environment: str = Field(description="Deposit type environment") group: str = Field(description="Deposit type group")