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

omb: accept dataframe #155

Merged
merged 1 commit into from
Dec 4, 2024
Merged

omb: accept dataframe #155

merged 1 commit into from
Dec 4, 2024

Conversation

gauteh
Copy link
Member

@gauteh gauteh commented Dec 4, 2024

@jerabaul29 opinions?

Use case:

#!/usr/bin/env python

import xarray as xr
import trajan as ta
import pandas as pd
import coloredlogs
import plz

coloredlogs.install('debug')

buoys = ['03', '10', '16', '17', '19', '20']

ds = [
    pd.read_csv(f'{b}.csv',
                names=['user', *ta.readers.omb.EXPECTED_COLUMNS, 'extra1'],
                header=0) for b in buoys
]
ds = pd.concat(ds)
ds = ta.readers.read_omb_csv(ds.drop('user', axis=1)).traj.assign_cf_attrs(
    creator_name='Gaute Hope',
    creator_email='[email protected]',
    title='ISMAR OMB deployment 2024',
    summary=' ',
    creator_institution='Norwegian Meteorological Institute')
ds.to_netcdf('2024-ismar-omb.nc')
print(ds)

@jerabaul29
Copy link
Collaborator

Looks good to me :) . I usually have a single csv that I read directly, but perfectly fine to me to support what you push if you use this workflow yourself :) .

@gauteh
Copy link
Member Author

gauteh commented Dec 4, 2024

Yeah, my problem is that I need to filter out only some of the buoys from the CSVs.

@gauteh gauteh merged commit 485458a into OpenDrift:main Dec 4, 2024
12 checks passed
@jerabaul29
Copy link
Collaborator

I think I would personally have "simply" done filtering of the CSV into a "reduced CSV" as a pre-processing step (typically I just take the CSV, and use my text editor to grep and delete the buoys entries I do not want, and then save it under a new name; maybe a bit "ugly", but works well enough ^^ ), and then parsed this "reduced CSV" as usual, but of course if you want to integrate this sort of functionality directly in trajan this is good to me :) .

@gauteh
Copy link
Member Author

gauteh commented Dec 4, 2024

I need an automated setup. Now I grep when downloading (in a script).

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.

2 participants