Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Transformation of ibracs #12

wants to merge 1 commit into from

Conversation

sudan45
Copy link

@sudan45 sudan45 commented Jan 22, 2025

Transformation of ibracs for events and hazard

@sudan45 sudan45 changed the title transformation of ibracs Transformation of ibracs Jan 22, 2025
Comment on lines +1 to +13
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
Copy link
Contributor

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")
Copy link
Contributor

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.

Comment on lines +34 to +40
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"
)
Copy link
Contributor

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..

Comment on lines +75 to +76
cleaned_data = df.iloc[2:].reset_index(drop=True)

Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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={},
Copy link
Contributor

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:

Suggested change
properties={},
properties={
"title": data.get("title"),
"description": data.get("place"),
"datetime": data.get("time"),
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

)
MontyExtension.add_to(item)
monty = MontyExtension.ext(item)
monty.episode_number = 1 # This should be dynamically determined based on existing events
Copy link
Contributor

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"]

Copy link
Contributor

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.

Comment on lines +153 to +158
return HazardDetail(
cluster="TC",
severity_value="",
severity_unit="",
estimate_type=MontyEstimateType.PRIMARY,
)
Copy link
Contributor

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.

Copy link
Contributor

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.

@emmanuelmathot emmanuelmathot self-requested a review January 29, 2025 10:18
Copy link
Collaborator

@emmanuelmathot emmanuelmathot left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants