-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transformation of ibracs #12
base: main
Are you sure you want to change the base?
Conversation
from pystac_monty.sources.common import MontyDataSource | ||
from pystac_monty.hazard_profiles import HazardProfiles | ||
import pandas as pd | ||
from typing import Any, List, Optional | ||
from shapely.geometry import Point, mapping | ||
from datetime import datetime | ||
import pytz | ||
import requests | ||
from pystac import Collection, Item, Link | ||
from pystac_monty.extension import HazardDetail, MontyExtension, MontyEstimateType | ||
from pystac_monty.hazard_profiles import HazardProfiles | ||
from pystac_monty.sources.common import MontyDataSource | ||
import json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets add this in order.
|
||
|
||
class NoaaIbtracsTransformer: | ||
print("NoaaIbtracsTransformer") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets add logger here and give meaingful message inside.
ibtracs_events_collection_url = ( | ||
"https://gitea.local.togglecorp.com/togglecorp/pystac-extension/raw/branch/main/examples/noaa-events/noaa-events.json" | ||
) | ||
|
||
ibtracs_hazards_collection_url = ( | ||
"https://gitea.local.togglecorp.com/togglecorp/pystac-extension/raw/branch/main/examples/noaa-events/noaa-events.json" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ADD # TODO here so that we dont forget to add collection url from monty-extension in the future..
cleaned_data = df.iloc[2:].reset_index(drop=True) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add why are we doing this ? Please add a comment here if possible.
|
||
try: | ||
item = self._create_event_item_from_row(row) | ||
print(item) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print(item) |
if item: | ||
event_items.append(item) | ||
except Exception as e: | ||
print(f"Error creating event item for SID {row.get('SID', 'unknown')}: {str(e)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print(f"Error creating event item for SID {row.get('SID', 'unknown')}: {str(e)}") | |
logger.error("Error creating event item for SID", exe_info=True, extra = { "SID": row.get('SID', 'unknown')}) |
geometry=geometry, | ||
bbox=bbox, | ||
datetime=datetime.strptime(row.get("ISO_TIME"), "%Y-%m-%d %H:%M:%S"), | ||
properties={}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets add properties here as:
properties={}, | |
properties={ | |
"title": data.get("title"), | |
"description": data.get("place"), | |
"datetime": data.get("time"), | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See here for more detail: https://github.com/IFRCGo/monty-stac-extension/tree/main/model/sources/USGS#event-item.
) | ||
MontyExtension.add_to(item) | ||
monty = MontyExtension.ext(item) | ||
monty.episode_number = 1 # This should be dynamically determined based on existing events |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add monty:country_codes
, monty:hazard_codes
, link
, 'correlation-id` as mentioned in this doc:https://github.com/IFRCGo/monty-stac-extension/tree/main/model/sources/USGS#event-item . See GDACS tranformation for event item for help.
hazard_item.id = hazard_item.id.replace(STAC_EVENT_ID_PREFIX, STAC_HAZARD_ID_PREFIX) | ||
hazard_item.set_collection(self.get_hazard_collection()) | ||
hazard_item.properties["roles"] = ["source", "hazard"] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add assests
as mentioned in doc: https://github.com/IFRCGo/monty-stac-extension/blob/main/model/sources/USGS/README.md#hazard-item-from-shakemap.
See gdacs transformer to add assets.
return HazardDetail( | ||
cluster="TC", | ||
severity_value="", | ||
severity_unit="", | ||
estimate_type=MontyEstimateType.PRIMARY, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thsi can be improved . See create_hazard_item for gdacs for more info. Follow https://github.com/IFRCGo/monty-stac-extension/blob/main/README.md#montyhazard_detail for creating hazard detail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may be we need to use mag
field for severity value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This transformer needs tests as per the other sources
Transformation of ibracs for events and hazard