Skip to content

Instantly share code, notes, and snippets.

@jurand71
Created April 2, 2023 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jurand71/19b6461c9d12e8fa1e1b1305de157a44 to your computer and use it in GitHub Desktop.
Save jurand71/19b6461c9d12e8fa1e1b1305de157a44 to your computer and use it in GitHub Desktop.
# list of interesting fields
gfs_variables = ['Temperature_surface','u-component_of_wind_isobaric','v-component_of_wind_isobaric',
'Total_cloud_cover_entire_atmosphere_Mixed_intervals_Average','Low_cloud_cover_low_cloud_Mixed_intervals_Average',
'Medium_cloud_cover_middle_cloud_Mixed_intervals_Average','High_cloud_cover_high_cloud_Mixed_intervals_Average',
'Total_cloud_cover_boundary_layer_cloud_Mixed_intervals_Average','Total_cloud_cover_convective_cloud']
gfs_columns = ['temp_air','wind_speed_u','wind_speed_v','total_clouds',
'low_clouds','mid_clouds','high_clouds','boundary_clouds','convect_clouds', 'time']
df = pd.DataFrame()
for gfs_variable in gfs_variables:
query = ncss.query()
query.lonlat_point(long, lat).vertical_level(100000).time_range(now, now + timedelta(days=forecast_days))
query.variables(gfs_variable).accept('netcdf')
data = ncss.get_data(query)
gfs_col = np.array(data.variables[gfs_variable][:].data)
df = pd.concat([df, pd.DataFrame(gfs_col)], axis=1)
time = data.variables['time']
dates = num2date(time[:], units=time.units, calendar='standard',
only_use_cftime_datetimes=False, only_use_python_datetimes=True)
df = pd.concat([df, pd.DataFrame(dates.data)], axis=1)
df.columns = gfs_columns
df.set_index('time', inplace=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment