最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Siphon - Cannot download data with all requested variables - Stack Overflow

matteradmin6PV0评论

I am trying to download weather forecast data using the Siphon library (example below). When I specify multiple variables to download, it downloads just some of them (print at the end shows just two of the requested). In the case below, it downloads data only for u-component_of_wind_isobaric and u-component_of_wind_isobaric, ignoring all others. If I comment out those two, it will download the first two. It seems to be limited to either 2 or 3 variables. Is it due to some API restrictions, or do I understand something wrong? I know I could make multiple requests, but it looks strange since it seems to be working in the past.

from datetime import datetime, timedelta

from siphon.catalog import TDSCatalog

variables = [
    'Temperature_surface',
    'Wind_speed_gust_surface',
    'u-component_of_wind_isobaric',
    'v-component_of_wind_isobaric',
    'Total_cloud_cover_entire_atmosphere_Mixed_intervals_Average',
]

best_gfs = TDSCatalog(
    '/'
    'Global_0p5deg/catalog.xml?dataset=grib/NCEP/GFS/Global_0p5deg/Best'
)
print(best_gfs.datasets)

ncss = best_gfs.datasets[0].subset()
query = ncss.query()

start, end = datetime.utcnow(), datetime.utcnow() + timedelta(days=1)
query.lonlat_point(17.918611, 59.651944).vertical_level(100000).time_range(start, end)

query.variables(*variables)
query.accept("netcdf4")

data = ncss.get_data(query)
print(list(data.variables))

Result: ['latitude', 'longitude', 'stationAltitude', 'station_id', 'station_description', 'u-component_of_wind_isobaric', 'v-component_of_wind_isobaric', 'time', 'stationIndex']

As seen most of requested variables missing in the result.

I am trying to download weather forecast data using the Siphon library (example below). When I specify multiple variables to download, it downloads just some of them (print at the end shows just two of the requested). In the case below, it downloads data only for u-component_of_wind_isobaric and u-component_of_wind_isobaric, ignoring all others. If I comment out those two, it will download the first two. It seems to be limited to either 2 or 3 variables. Is it due to some API restrictions, or do I understand something wrong? I know I could make multiple requests, but it looks strange since it seems to be working in the past.

from datetime import datetime, timedelta

from siphon.catalog import TDSCatalog

variables = [
    'Temperature_surface',
    'Wind_speed_gust_surface',
    'u-component_of_wind_isobaric',
    'v-component_of_wind_isobaric',
    'Total_cloud_cover_entire_atmosphere_Mixed_intervals_Average',
]

best_gfs = TDSCatalog(
    'http://thredds.ucar.edu/thredds/catalog/grib/NCEP/GFS/'
    'Global_0p5deg/catalog.xml?dataset=grib/NCEP/GFS/Global_0p5deg/Best'
)
print(best_gfs.datasets)

ncss = best_gfs.datasets[0].subset()
query = ncss.query()

start, end = datetime.utcnow(), datetime.utcnow() + timedelta(days=1)
query.lonlat_point(17.918611, 59.651944).vertical_level(100000).time_range(start, end)

query.variables(*variables)
query.accept("netcdf4")

data = ncss.get_data(query)
print(list(data.variables))

Result: ['latitude', 'longitude', 'stationAltitude', 'station_id', 'station_description', 'u-component_of_wind_isobaric', 'v-component_of_wind_isobaric', 'time', 'stationIndex']

As seen most of requested variables missing in the result.

Share Improve this question asked Nov 18, 2024 at 10:54 PrimozPrimoz 1,4942 gold badges19 silver badges37 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

A limitation of the NCSS service you're trying to use is that it can only return variables on a single coordinate system (e.g. combination of horizontal coords + vertical coord + time). The first two variables use one vertical coordinate, the second two use a different one, and last variable yet another vertical coordinate. You'll need to separate this into 3 different requests.

You can see the variables grouped by coordinate system on the web form for NCSS for that dataset.

Post a comment

comment list (0)

  1. No comments so far