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

argopy code samples and access patterns #1

Open
emiliom opened this issue Aug 8, 2023 · 3 comments
Open

argopy code samples and access patterns #1

emiliom opened this issue Aug 8, 2023 · 3 comments

Comments

@emiliom
Copy link
Member

emiliom commented Aug 8, 2023

I'll include some examples and notes for access to Argo data via the argopy package.

The materials in the Argo Online School can be helpful, too. Most of the lessons don't use argopy, though. See Accessing Argo data by float using Argopy and Accessing Argo data by date using Argopy. But keep in mind that these notebooks may have some subtle glitches (based on personal experience last month).

Load all data for a specified float

Get only data that meets the top quality control (qc) flag.

from argopy import DataFetcher as ArgoDataFetcher

argo_loader = ArgoDataFetcher(src='erddap', parallel=True, qc=1)

float_id = 5903608

# Load "point" data
float_ds = argo_loader.float(float_id).load().data
# Restructure the data to a "profile" organization
float_profile_ds = float_ds.argo.point2profile()

float_ds and float_profile_ds are xarray Datasets

@emiliom
Copy link
Member Author

emiliom commented Aug 9, 2023

I've also tried using the ArgoDataFetcher region request, but have either obtained suspicious results or it takes too long. For example, a statement like this:

argo_loader.region([-147, -138, 24, 36, 0, 10000, '1999-01-01', '2023-01-01']).load()

Supposedly one should be able to generate an xarray Dataset if you call the .data() method on that statement, but sometimes it fails. The documentation and the Argo Online School lessons are fairly uneven in this respect.

What I found successful, but indirect, was to use

from argopy import IndexFetcher as ArgoIndexFetcher

idx = ArgoIndexFetcher(src='erddap').region([-147, -138, 24, 36, '1999-01-01', '2023-01-01']).load()

Then idx.index is a Pandas Dataframe with information (but not data) about float deployments that meet the spatial and temporal criteria in region. It looks like this:

image

You would then need to request data float by float with the ArgoDataFetcher float() method.

@RobUrick
Copy link
Collaborator

RobUrick commented Aug 9, 2023

I've also had inconsistent results using ArgoDataFetch.region. I've used it and gotten back good results, but then used the same statement and it's failed.

For reference I am using this the to_xarray method, as documented here.

from argopy import DataFetcher as ArgoDataFetcher

lower_lat = 20
upper_lat = 40
lower_long = -45
upper_long = -25
lower_press = 0
upper_press = 100

start = '2022-06'
end = '2023-06'

ds = ArgoDataFetcher().region([lower_long, upper_long, lower_lat, upper_lat, lower_press, upper_press, start, end]).to_xarray()

EDIT: I've run it a number of times this morning without issue so might have just been a server-side or connection issue.

@emiliom
Copy link
Member Author

emiliom commented Aug 9, 2023

For reference I am using this the to_xarray method, as documented here.

Great! I remember running into that.

But:

I've also had inconsistent results using ArgoDataFetch.region. I've used it and gotten back good results, but then used the same statement and it's failed.

Exactly. And I've also had uneven results, where the date range I passed sometimes clearly missed data.

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

No branches or pull requests

2 participants