コード例 #1
0
Since multiple files are created, also create a text file that can be loaded
into GNOME pointing to the individual files
'''

out_dir = 'ngofs'

# start = dt.date(2018,10,2)
# end = dt.date(2018,10,4)
# date = start
# dates = []
# while date <= end:
# dates.append(date)
# date += datetime.timedelta(days=1)
#flist = ['fvcom_maine' + str(d.year) + str(d.month).zfill(2) + str(d.day).zfill(2) for d in dates]

flist = noaa_coops.make_server_filelist('ngofs', dt.date(2020, 10, 21))

# the utools class requires a mapping of specific model variable names (values)
# to common names (keys) so that the class methods can work with FVCOM, SELFE,
# and ADCIRC which have different variable names
# (This seemed easier than finding them by CF long_names etc)
var_map = { 'longitude':'lon', \
            'latitude':'lat', \
            'time':'time', \
            'u_velocity':'u', \
            'v_velocity':'v', \
            'nodes_surrounding_ele':'nv',\
            'eles_surrounding_ele':'nbe',\
          }

# class instantiation creates a netCDF Dataset object as an attribute --
コード例 #2
0
from __future__ import print_function
from libgoods import curv_grid, nctools, noaa_coops, data_files_dir
import os
import datetime as dt


start = dt.date(2015,3,9)
end = dt.date(2015,3,9)
hour0 = 0
flist = noaa_coops.make_server_filelist('dbofs',hour0,start,end=end,test_exist=False)

var_map = { 'time':'ocean_time',
           }  
subset = 0
slat = 38.8
nlat = 39.2
wlon = -75.4
elon = -74.8

fnum = 0

dbofs = curv_grid.roms(flist[0])
dbofs.get_dimensions(var_map)
dbofs.data['lon'] = dbofs.data['lon_psi']
dbofs.data['lat'] = dbofs.data['lat_psi']
if subset:
    dbofs.subset([slat,wlon,nlat,elon])
    dbofs.get_grid_info(yindex=dbofs.y,xindex=dbofs.x)
else:
    dbofs.get_grid_info()
コード例 #3
0
#!/usr/bin/env python
from __future__ import print_function
from libgoods import roms_model, nctools, noaa_coops, data_files_dir
import datetime as dt
import os

reload(roms_model)

out_dir = os.path.join(data_files_dir, 'tbofs')
if not os.path.exists(out_dir):
    os.mkdir(out_dir)
# specify local file or opendap url

sdate = dt.date(2020, 1, 18)
edate = dt.date(2020, 1, 22)
flist = noaa_coops.make_server_filelist('tbofs', sdate)
print("Number of files to aggregate: ", len(flist))

model = roms_model.roms(flist[0])
print('getting dimensions')
model.get_dimensions()

for f in flist:
    print(f)
    if f != flist[0]:
        model.update(f)
        model.get_dimensions(get_xy=False)
    model.when()
    print('writing file')
    coops_name = f.split('/')[-1].split('.')
    ofn = coops_name[1] + '_' + coops_name[4] + '_' + coops_name[
コード例 #4
0
from libgoods import curv_grid, nctools, data_files_dir, noaa_coops
import datetime as dt
import os

flist = noaa_coops.make_server_filelist('nyofs',
                                        5,
                                        dt.date(2018, 12, 10),
                                        end=None,
                                        test_exist=True)
url = 'http://opendap.co-ops.nos.noaa.gov/thredds/dodsC/NYOFS/fmrc/Aggregated_7_day_NYOFS_Fields_Forecast_best.ncd'

var_map = nctools.get_var_map(
    url,
    var_list=['longitude', 'latitude', 'time', 'u_velocity', 'v_velocity'])

nyofs = curv_grid.cgrid(url)
nyofs.get_dimensions(var_map)

subset = 1
tlen = len(nyofs.data['time'])

if subset:
    nyofs.subset([40.566, -74.114, 40.654, -74.012])
    nyofs.get_grid_info(var_map, yindex=nyofs.y, xindex=nyofs.x)
    nyofs.get_data(var_map, yindex=nyofs.y, xindex=nyofs.x)
    ofn = os.path.join(data_files_dir, 'nyofs_example.nc')
    nyofs.write_nc(ofn)
else:
    nyofs.get_grid_info(var_map)
    nyofs.get_data(var_map, tindex=[tlen - 5, tlen, 1])
    ofn = os.path.join(data_files_dir, 'nyofs_example.nc')
コード例 #5
0
#!/usr/bin/env python
from libgoods import tri_grid, nctools, noaa_coops, data_files_dir
import os 
import datetime as dt
from netCDF4 import Dataset
'''
Sample script to retrieve data from NOAA CO-OPS FVCOM netcdf "file" (can be
OPeNDAP url), generate necessary grid topology (boundary info), and write 
GNOME compatible output.

'''
# specify local file or opendap url
start = dt.date(2015,3,9)
hour0 = 3
flist = noaa_coops.make_server_filelist('nwgofs',hour0,start,test_exist=False)
#data_url = 'http://opendap.co-ops.nos.noaa.gov/thredds/dodsC/NOAA/NWGOFS/MODELS/201501/nos.nwgofs.fields.f001.20150102.t15z.nc'
# the utools class requires a mapping of specific model variable names (values)
# to common names (keys) so that the class methods can work with FVCOM, SELFE,
# and ADCIRC which have different variable names
# (This seemed easier than finding them by CF long_names etc)
var_map = { 'longitude':'lon', \
            'latitude':'lat', \
            'time':'time', \
            'u_velocity':'u', \
            'v_velocity':'v', \
            'nodes_surrounding_ele':'nv',\
            'eles_surrounding_ele':'nbe',\
            'sigma':'siglay',\
            'depth':'h',\
          }  
コード例 #6
0
Since multiple files are created, also create a text file that can be loaded
into GNOME pointing to the individual files
'''

out_dir = 'ngofs'

# start = dt.date(2018,10,2)
# end = dt.date(2018,10,4)
# date = start
# dates = []
# while date <= end:
    # dates.append(date)
    # date += datetime.timedelta(days=1)	
#flist = ['fvcom_maine' + str(d.year) + str(d.month).zfill(2) + str(d.day).zfill(2) for d in dates]

flist = noaa_coops.make_server_filelist('ngofs',3,dt.date(2019,5,30),end=None,test_exist=False)

# the utools class requires a mapping of specific model variable names (values)
# to common names (keys) so that the class methods can work with FVCOM, SELFE,
# and ADCIRC which have different variable names
# (This seemed easier than finding them by CF long_names etc)
var_map = { 'longitude':'lon', \
            'latitude':'lat', \
            'time':'time', \
            'u_velocity':'u', \
            'v_velocity':'v', \
            'nodes_surrounding_ele':'nv',\
            'eles_surrounding_ele':'nbe',\
          }  

コード例 #7
0
#!/usr/bin/env python
from libgoods import tri_grid, nctools, noaa_coops, data_files_dir
import os
import datetime as dt
from netCDF4 import Dataset
'''
Sample script to retrieve data from NOAA CO-OPS FVCOM netcdf "file" (can be
OPeNDAP url), generate necessary grid topology (boundary info), and write 
GNOME compatible output.

'''
# specify local file or opendap url
start = dt.date(2015, 3, 9)
hour0 = 3
flist = noaa_coops.make_server_filelist('nwgofs',
                                        hour0,
                                        start,
                                        test_exist=False)
#data_url = 'http://opendap.co-ops.nos.noaa.gov/thredds/dodsC/NOAA/NWGOFS/MODELS/201501/nos.nwgofs.fields.f001.20150102.t15z.nc'
# the utools class requires a mapping of specific model variable names (values)
# to common names (keys) so that the class methods can work with FVCOM, SELFE,
# and ADCIRC which have different variable names
# (This seemed easier than finding them by CF long_names etc)
var_map = { 'longitude':'lon', \
            'latitude':'lat', \
            'time':'time', \
            'u_velocity':'u', \
            'v_velocity':'v', \
            'nodes_surrounding_ele':'nv',\
            'eles_surrounding_ele':'nbe',\
            'sigma':'siglay',\
            'depth':'h',\