def load_scenarios(mydate, scenario_ids=range(0, 21), latBound=[-90, 90], lonBound=[0, 360], timeSteps=[0, 64]): """ Loads previously downloaded scenarios and returns the corresponding list of :class:`weatherTLKT.Weather` objects. :param string mydate: 'yyyymmdd' date of the day starting the weather forecast in US format :param scenario_ids: range covering the forecasts scenarios we want to download :param list(float,float) latBound: [latmin, latmax], latitude boundaries of the domain on which the forecast is desired. If smaller than domain of stored object, returns a cropped object. Returns stored object otherwise :param list(float,float) lonBound: [lonmin, lonmax], longitude boundaries of the domain on which the forecast is desired. If smaller than domain of stored object, returns a cropped object. Returns stored object otherwise :param list(int,int) timeSteps: [min_t_index, max_t_index], time span of the desired forecast. If smaller than domain of stored object, returns a cropped object. Returns stored object otherwise :return: List of of :class:`weatherTLKT.Weather` :rtype: list() """ pathToSaveObj = [] weather_scen = [] for ii in scenario_ids: if ii < 10: s_id = '0' + str(ii) else: s_id = str(ii) pathToSaveObj.append(('../data/' + mydate + '_' + s_id + '00z.obj')) weather_scen.append( Weather.load(pathToSaveObj[ii], latBound, lonBound, timeSteps)) print("Loaded : " + pathToSaveObj[-1]) return weather_scen
import copy import pickle import sys sys.path.append("../solver") #from MyTree import Tree from worker import Tree # %% We load the forecast files #ATTENTION il faudra prendre le fichier de vent moyen à terme!!! mydate = '20180108' modelcycle = '0100z' pathToSaveObj = '../data/' + mydate + '_gep_' + modelcycle + '.obj' Wavg = Weather.load(pathToSaveObj) Wavg=Wavg.crop(latBound=[40, 50], lonBound=[360 - 15, 360]) #mydate = '20170519' #modelcycle = '00' #pathToSaveObj = '../data/' + mydate + '_' + modelcycle + '.obj' #Wavg = Weather.load(pathToSaveObj) # %% We shift the times so that all times are in the correct bounds for interpolations Tini = Wavg.time[0] Wavg.time = Wavg.time - Tini # %% We set up the parameters of the simulation # times=np.arange(0,min([Wavg.time[-1],Wspr.time[-1]]),1*HOURS_TO_DAY) # Tf=len(times)
lonBound = [-10 + 360, 360] url = [] pathToSaveObj = [] urlold = 'http://nomads.ncep.noaa.gov:9090/dods/gfs_0p25/gfs20171014/gfs_0p25_00z' for i in range(2): url.append(website + 'gfs_' + resolution[i] + '/gfs' + mydate + '/gfs_' + resolution[i] + '_' + modelcycle + 'z') pathToSaveObj.append('../data/' + mydate + '_gfs_' + resolution[i] + '.obj') # launch in real python console # Weather.download(url[0],pathToSaveObj[0],latBound=latBound,lonBound=lonBound,timeSteps=[0,81]) # Weather.download(url[1],pathToSaveObj[1],latBound=latBound,lonBound=lonBound,timeSteps=[0,81]) # %% weather025 = Weather.load(pathToSaveObj[0]) weather1 = Weather.load(pathToSaveObj[1]) instant = 40 #weather025.plotMultipleQuiver(otherWeather = weather1) time = weather025.time[instant] weather1.Interpolators() error = np.zeros((len(weather025.lat), len(weather025.lon))) interp_u = np.zeros((len(weather025.lat), len(weather025.lon))) interp_v = np.zeros((len(weather025.lat), len(weather025.lon))) for i, lat in enumerate(weather025.lat): for j, lon in enumerate(weather025.lon): if lat >= min(weather1.lat) and lat <= max( weather1.lat) and lon >= min(weather1.lon) and lon <= max( weather1.lon):