def main(Dir, Startdate, Enddate, latlim, lonlim, cores=False, Waitbar=1): """ This function downloads MSWEP precipitation daily data for a given variable, time interval, and spatial extent. Keyword arguments: Dir -- 'C:/file/to/path/' Startdate -- 'yyyy-mm-dd' Enddate -- 'yyyy-mm-dd' latlim -- [ymin, ymax] lonlim -- [xmin, xmax] Waitbar -- 1 (Default) Will print a waitbar """ if Waitbar == 1: print '\nDownloading daily MSWEP precipitation data for the period %s till %s' % ( Startdate, Enddate) # Download data DownloadData(Dir, Startdate, Enddate, latlim, lonlim, Waitbar, cores, TimeCase='daily')
def main(Dir, Startdate='', Enddate='', latlim=[-60, 70], lonlim=[-180, 180], Waitbar=1): """ This function downloads monthly ALEXI data Keyword arguments: Dir -- 'C:/file/to/path/' Startdate -- 'yyyy-mm-dd' Enddate -- 'yyyy-mm-dd' latlim -- [ymin, ymax] (values must be between -60 and 70) lonlim -- [xmin, xmax] (values must be between -180 and 180) """ print '\nDownload monthly ALEXI evapotranspiration data for the period %s till %s' % ( Startdate, Enddate) # Download data DownloadData(Dir, Startdate, Enddate, latlim, lonlim, Waitbar) # Define directory Dir_ALEXI_Weekly = os.path.join(Dir, 'Evaporation', 'ALEXI', 'Weekly') Dir_ALEXI_Monthly = os.path.join(Dir, 'Evaporation', 'ALEXI', 'Monthly') # Create output directory if not os.path.exists(Dir_ALEXI_Monthly): os.mkdir(Dir_ALEXI_Monthly) # Create monthly maps based on weekly maps import wa.Functions.Start.Weekly_to_monthly_flux as Week2month Week2month.Nearest_Interpolate(Dir_ALEXI_Weekly, Startdate, Enddate, Dir_ALEXI_Monthly)
def main(Dir, Startdate='', Enddate='', latlim=[-50, 50], lonlim=[-180, 180], cores=False, Waitbar=1): """ This function downloads daily CHIRPS data Keyword arguments: Dir -- 'C:/file/to/path/' Startdate -- 'yyyy-mm-dd' Enddate -- 'yyyy-mm-dd' latlim -- [ymin, ymax] (values must be between -50 and 50) lonlim -- [xmin, xmax] (values must be between -180 and 180) cores -- The number of cores used to run the routine. It can be 'False' to avoid using parallel computing routines. Waitbar -- 1 (Default) will print a waitbar """ print '\nDownload daily CHIRPS rainfall data for the period %s till %s' % ( Startdate, Enddate) # Download data DownloadData(Dir, Startdate, Enddate, latlim, lonlim, Waitbar, cores, TimeCase='daily')
def main(Dir, Startdate, Enddate, latlim, lonlim, cores=False, Waitbar=1, hdf_library=None, remove_hdf=1): """ This function downloads MOD15 16-daily data for the specified time interval, and spatial extent. Keyword arguments: Dir -- 'C:/file/to/path/' Startdate -- 'yyyy-mm-dd' Enddate -- 'yyyy-mm-dd' latlim -- [ymin, ymax] lonlim -- [xmin, xmax] cores -- amount of cores used Waitbar -- 1 (Default) will print a waitbar """ nameDownload = 'Lai_500m' print '\nDownload 8-daily MODIS LAI data for period %s till %s' % ( Startdate, Enddate) DownloadData(Dir, Startdate, Enddate, latlim, lonlim, Waitbar, cores, nameDownload, hdf_library, remove_hdf)
def main(Dir, Startdate, Enddate, latlim, lonlim, Waitbar=1): """ This function downloads ETensemble data for the specified time interval, and spatial extent. Keyword arguments: Dir -- 'C:/file/to/path/' Startdate -- 'yyyy-mm-dd' Enddate -- 'yyyy-mm-dd' latlim -- [ymin, ymax] lonlim -- [xmin, xmax] Waitbar -- 1 (Default) Will print a waitbar """ # Check the start and enddate if not Startdate: Startdate = pd.Timestamp('2003-01-01') if not Enddate: Enddate = pd.Timestamp('2014-12-31') # Check and adjust if needed the latitude and longitude if latlim[0] < -90 or latlim[1] > 90: print 'Latitude above 90N or below 90S is not possible. Value set to maximum' latlim[0] = np.max(latlim[0], -90) latlim[1] = np.min(latlim[1], 90) if lonlim[0] < -180 or lonlim[1] > 180: print 'Longitude must be between 180E and 180W. Now value is set to maximum' lonlim[0] = np.max(lonlim[0], -180) lonlim[1] = np.min(lonlim[1], 180) print '/nCreate monthly ETensemble maps for period %s till %s' % ( Startdate, Enddate) # Download and create the ET data DownloadData(Dir, Startdate, Enddate, latlim, lonlim, Waitbar)
def main(Dir, Startdate, Enddate, latlim, lonlim, LC_Types=[1], cores=False, Waitbar=1): """ This function downloads MOD12 yearly LC data for the specified time interval, and spatial extent. Keyword arguments: Dir -- 'C:/file/to/path/' Startdate -- 'yyyy-mm-dd' Enddate -- 'yyyy-mm-dd' latlim -- [ymin, ymax] lonlim -- [xmin, xmax] cores -- amount of cores used Waitbar -- 1 (Default) will print a waitbar """ for LC_Type in LC_Types: print '\nDownload yearly MODIS LC%d data for period %s till %s' % ( LC_Type, Startdate, Enddate) DownloadData(Dir, Startdate, Enddate, latlim, lonlim, LC_Type, Waitbar, cores)
def main(Dir, Vars, Startdate, Enddate, latlim, lonlim, cores=False, Periods=[1, 2, 3, 4, 5, 6, 7, 8], Waitbar=1, gldas_version='2.1'): """ This function downloads GLDAS three-hourly data for a given variable, time interval, spatial extent, and day period. Keyword arguments: Dir -- 'C:/file/to/path/' Var -- ['wind_f_inst','qair_f_inst'] Variable code. Run: VariablesInfo('day').descriptions.keys() Startdate -- 'yyyy-mm-dd' Enddate -- 'yyyy-mm-dd' latlim -- [ymin, ymax] lonlim -- [xmin, xmax] Periods -- List of numbers from 1 to 8 (e.g. [1,4,5,8]). Stands for the period of hour of a day as follows: Period Hours 1 00:00 - 03:00 2 03:00 - 06:00 3 06:00 - 09:00 4 09:00 - 12:00 5 12:00 - 15:00 6 15:00 - 18:00 7 18:00 - 21:00 8 21:00 - 24:00 Waitbar -- 1 (Default) Will print a waitbar gldas_version = '2.1' (Default) or '2.0' Version 2.1 is available from 2000-01-01 till present Version 2.0 is available from 1948-01-01 till 2010-12-31 """ for Var in Vars: if Waitbar == 1: print '\nDownloading 3-hourly GLDAS %s data for the period %s till %s' % ( Var, Startdate, Enddate) # Download data DownloadData(Dir, Var, Startdate, Enddate, latlim, lonlim, Waitbar, cores, TimeCase='three_hourly', CaseParameters=Periods, gldas_version=gldas_version) # Download data
def main(Dir, latlim, lonlim, Waitbar=1): """ This function downloads JRC water occurrence data for the specified spatial extent. Keyword arguments: Dir -- 'C:/file/to/path/' latlim -- [ymin, ymax] lonlim -- [xmin, xmax] Waitbar -- 1 (Default) will print a waitbar """ print '\nDownload JRC occurrence map' DownloadData(Dir, latlim, lonlim, Waitbar)
def main(Dir, latlim=[-60, 84], lonlim=[-180, 180]): """ This function downloads gray water footprint data Keyword arguments: Dir -- 'C:/file/to/path/' latlim -- [ymin, ymax] (values must be between -60 and 84) lonlim -- [xmin, xmax] (values must be between -180 and 180) """ # Download data DownloadData(Dir, latlim, lonlim)
def main(Dir, Startdate='', Enddate='', latlim=[-60, 70], lonlim=[-180, 180]): """ This function downloads weekly ALEXI data Keyword arguments: Dir -- 'C:/file/to/path/' Startdate -- 'yyyy-mm-dd' Enddate -- 'yyyy-mm-dd' latlim -- [ymin, ymax] (values must be between -60 and 70) lonlim -- [xmin, xmax] (values must be between -180 and 180) """ # Download data DownloadData(Dir, Startdate, Enddate, latlim, lonlim)
def main(Dir, latlim=[-90, 90], lonlim=[-180, 180], Waitbar=1): """ This function downloads HiHydrosoil data Keyword arguments: Dir -- 'C:/file/to/path/' latlim -- [ymin, ymax] (values must be between 90 and 90) lonlim -- [xmin, xmax] (values must be between -180 and 180) """ print '\nDownload monthly HiHydroSoil Theta Saturated data of the top soil' # Download data DownloadData(Dir, latlim, lonlim, Waitbar)
def main(Dir, Vars, Startdate, Enddate, latlim, lonlim, cores=False, SumMean=1, Min=0, Max=0, Waitbar=1, gldas_version='2.1'): """ This function downloads GLDAS daily data for a given variable, time interval, and spatial extent. Keyword arguments: Dir -- 'C:/file/to/path/' Vars -- ['wind_f_inst','qair_f_inst'] (array of strings) Variable code: VariablesInfo('day').descriptions.keys() Startdate -- 'yyyy-mm-dd' Enddate -- 'yyyy-mm-dd' latlim -- [ymin, ymax] lonlim -- [xmin, xmax] SumMean -- 0 or 1. Indicates if the output values are the daily mean for instantaneous values or sum for fluxes Min -- 0 or 1. Indicates if the output values are the daily minimum Max -- 0 or 1. Indicates if the output values are the daily maximum Waitbar -- 1 (Default) Will print a waitbar gldas_version = '2.1' (Default) or '2.0' Version 2.1 is available from 2000-01-01 till present Version 2.0 is available from 1948-01-01 till 2010-12-31 """ for Var in Vars: if Waitbar == 1: print '\nDownloading daily GLDAS %s data for the period %s till %s' % ( Var, Startdate, Enddate) # Download data DownloadData(Dir, Var, Startdate, Enddate, latlim, lonlim, Waitbar, cores, TimeCase='daily', CaseParameters=[SumMean, Min, Max], gldas_version=gldas_version)
def main(Dir, Startdate='', Enddate='', latlim=[-59.17, 80], lonlim=[-180, 180], Waitbar = 1): """ This function downloads monthly SSEBop data Keyword arguments: Dir -- 'C:/file/to/path/' Startdate -- 'yyyy-mm-dd' Enddate -- 'yyyy-mm-dd' latlim -- [ymin, ymax] (values must be between -59.17 and 80) lonlim -- [xmin, xmax] (values must be between -180 and 180) """ print '\nDownload monthly SSEBop evapotranspiration data for the period %s till %s' %(Startdate, Enddate) # Download data DownloadData(Dir, Startdate, Enddate, latlim, lonlim, Waitbar)
def main(Dir, Startdate='', Enddate='', latlim=[-60, 70], lonlim=[-180, 180], Waitbar = 1): """ This function downloads monthly ETmonitor data Keyword arguments: Dir -- 'C:/file/to/path/' Startdate -- 'yyyy-mm-dd' Enddate -- 'yyyy-mm-dd' latlim -- [ymin, ymax] (values must be between -60 and 70) lonlim -- [xmin, xmax] (values must be between -180 and 180) """ print '\nDownload monthly ETmonitor Interception data for the period %s till %s' %(Startdate, Enddate) Type = "ei" # Download data DownloadData(Dir, Startdate, Enddate, latlim, lonlim, Type, Waitbar)
def main(Dir, Startdate='', Enddate='', latlim=[-60, 70], lonlim=[-180, 180], Waitbar=1): """ This function downloads daily ASCAT data Keyword arguments: Dir -- 'C:/file/to/path/' Startdate -- 'yyyy-mm-dd' Enddate -- 'yyyy-mm-dd' latlim -- [ymin, ymax] (values must be between -60 and 70) lonlim -- [xmin, xmax] (values must be between -180 and 180) """ print '\nDownload daily ASCAT SWI data for the period %s till %s'\ % (Startdate, Enddate) # Download data DownloadData(Dir, Startdate, Enddate, latlim, lonlim, Waitbar)
def main(Dir, Startdate, Enddate, latlim, lonlim, cores=False, Waitbar=1): """ This function downloads MOD9 reflectance daily data for the specified time interval, and spatial extent. Keyword arguments: Dir -- 'C:/file/to/path/' Startdate -- 'yyyy-mm-dd' Enddate -- 'yyyy-mm-dd' latlim -- [ymin, ymax] lonlim -- [xmin, xmax] cores -- amount of cores used Waitbar -- 1 (Default) will print a waitbar """ print '\nDownload daily MODIS Reflectance data for period %s till %s' % ( Startdate, Enddate) DownloadData(Dir, Startdate, Enddate, latlim, lonlim, Waitbar, cores)
def main(Dir, Vars, Startdate, Enddate, latlim, lonlim, cores=False, SumMean=1, Min=0, Max=0, Waitbar=1): """ This function downloads ECMWF daily data for a given variable, time interval, and spatial extent. Keyword arguments: Dir -- 'C:/file/to/path/' Var -- Variable code: VariablesInfo('day').descriptions.keys() Startdate -- 'yyyy-mm-dd' Enddate -- 'yyyy-mm-dd' latlim -- [ymin, ymax] lonlim -- [xmin, xmax] SumMean -- 0 or 1. Indicates if the output values are the daily mean for instantaneous values or sum for fluxes Min -- 0 or 1. Indicates if the output values are the daily minimum Max -- 0 or 1. Indicates if the output values are the daily maximum Waitbar -- 1 (Default) will create a waitbar """ for Var in Vars: # Download data print '\nDownload ECMWF %s data for period %s till %s' % ( Var, Startdate, Enddate) DownloadData(Dir, Var, Startdate, Enddate, latlim, lonlim, Waitbar, cores, TimeCase='daily', CaseParameters=[SumMean, Min, Max]) del_ecmwf_dataset = os.path.join(Dir, 'data_interim.nc') os.remove(del_ecmwf_dataset)
def main(Dir, Startdate, Enddate, latlim, lonlim, cores=False, Waitbar = 1, hdf_library = None, remove_hdf = 1): """ This function downloads MOD11 daily data for the specified time interval, and spatial extent. Keyword arguments: Dir -- 'C:/file/to/path/' Startdate -- 'yyyy-mm-dd' Enddate -- 'yyyy-mm-dd' latlim -- [ymin, ymax] lonlim -- [xmin, xmax] cores -- amount of cores used Waitbar -- 1 (Default) will print a waitbar """ print '\nDownload daily MODIS land surface temperature data for period %s till %s' %(Startdate, Enddate) TimeStep = 1 DownloadData(Dir, Startdate, Enddate, latlim, lonlim, TimeStep, Waitbar, cores, hdf_library, remove_hdf)
def main(Dir, Vars, Startdate, Enddate, latlim, lonlim, cores=False, Waitbar=1, gldas_version='2.1'): """ This function downloads GLDAS monthly data for a given variable, time interval, and spatial extent. Keyword arguments: Dir -- 'C:/file/to/path/' Var -- ['wind_f_inst','qair_f_inst'] Variable code: VariablesInfo('day').descriptions.keys() Startdate -- 'yyyy-mm-dd' Enddate -- 'yyyy-mm-dd' latlim -- [ymin, ymax] lonlim -- [xmin, xmax] Waitbar -- 1 (Default) Will print a waitbar gldas_version = '2.1' (Default) or '2.0' Version 2.1 is available from 2000-01-01 till present Version 2.0 is available from 1948-01-01 till 2010-12-31 """ for Var in Vars: if Waitbar == 1: print '\nDownloading monthly GLDAS %s data for the period %s till %s' % ( Var, Startdate, Enddate) # Download data DownloadData(Dir, Var, Startdate, Enddate, latlim, lonlim, Waitbar, cores, TimeCase='monthly', CaseParameters=False, gldas_version=gldas_version)
def main(Dir, Startdate, Enddate, latlim, lonlim, cores=False, Waitbar=1): """ This function downloads GLEAM monthly data for the specified time interval, and spatial extent. Keyword arguments: Dir -- 'C:/file/to/path/' Startdate -- 'yyyy-mm-dd' Enddate -- 'yyyy-mm-dd' latlim -- [ymin, ymax] lonlim -- [xmin, xmax] cores -- amount of cores used Waitbar -- 1 (Default) will print a waitbar """ TimeCase = 'monthly' print '\nDownload monthly GLEAM ET data for the period %s till %s' % ( Startdate, Enddate) DownloadData(Dir, Startdate, Enddate, latlim, lonlim, Waitbar, cores, TimeCase)
def main(Dir, Startdate, Enddate, latlim, lonlim, cores=False, Waitbar = 1, hdf_library = None, remove_hdf = 1): """ This function downloads MOD16 8-daily data for the specified time interval, and spatial extent. Keyword arguments: Dir -- 'C:/file/to/path/' Startdate -- 'yyyy-mm-dd' Enddate -- 'yyyy-mm-dd' latlim -- [ymin, ymax] lonlim -- [xmin, xmax] cores -- amount of cores used Waitbar -- 1 (Default) will print a waitbar Dir = "C:/testMOD" Startdate = "2003-11-01" Enddate = "2004-01-06" latlim =[17,30] lonlim=[93,100] """ print '\nDownload 8-daily MODIS ET data for period %s till %s' %(Startdate, Enddate) timestep = '8-daily' DownloadData(Dir, Startdate, Enddate, latlim, lonlim, timestep, Waitbar, cores, hdf_library, remove_hdf)
def main(Dir, Startdate='', Enddate='', latlim=[-60, 70], lonlim=[-180, 180], Waitbar=1): """ This function downloads weekly ALEXI data Keyword arguments: Dir -- 'C:/file/to/path/' Startdate -- 'yyyy-mm-dd' Enddate -- 'yyyy-mm-dd' latlim -- [ymin, ymax] (values must be between -60 and 70) lonlim -- [xmin, xmax] (values must be between -180 and 180) """ print '\nDownload weekly ALEXI evapotranspiration data for the period %s till %s' % ( Startdate, Enddate) TimeStep = 'weekly' # Download data DownloadData(Dir, Startdate, Enddate, latlim, lonlim, TimeStep, Waitbar)
def main(Dir, Startdate='', Enddate='', latlim=[-50, 50], lonlim=[-180, 180], cores=False, Waitbar=1): """ This function downloads RFE V2.0 (monthly) data Keyword arguments: Dir -- 'C:/file/to/path/' Startdate -- 'yyyy-mm-dd' Enddate -- 'yyyy-mm-dd' latlim -- [ymin, ymax] (values must be between -50 and 50) lonlim -- [xmin, xmax] (values must be between -180 and 180) cores -- The number of cores used to run the routine. It can be 'False' to avoid using parallel computing routines. Waitbar -- 1 (Default) will print a waitbar """ # Download data print '\nDownload monthly RFE precipitation data for period %s till %s' % ( Startdate, Enddate) # Check variables if not Startdate: Startdate = pd.Timestamp('2001-01-01') if not Enddate: Enddate = pd.Timestamp('Now') Dates = pd.date_range(Startdate, Enddate, freq='MS') # Make directory output_folder = os.path.join(Dir, 'Precipitation', 'RFE', 'Monthly/') if not os.path.exists(output_folder): os.makedirs(output_folder) # Create Waitbar if Waitbar == 1: import wa.Functions.Start.WaitbarConsole as WaitbarConsole total_amount = len(Dates) amount = 0 WaitbarConsole.printWaitBar(amount, total_amount, prefix='Progress:', suffix='Complete', length=50) for Date in Dates: month = Date.month year = Date.year end_day = calendar.monthrange(year, month)[1] Startdate_one_month = '%s-%02s-01' % (year, month) Enddate_one_month = '%s-%02s-%02s' % (year, month, end_day) DownloadData(Dir, Startdate_one_month, Enddate_one_month, latlim, lonlim, 0, cores) Dates_daily = pd.date_range(Startdate_one_month, Enddate_one_month, freq='D') # Make directory input_folder_daily = os.path.join(Dir, 'Precipitation', 'RFE', 'Daily/') i = 0 for Date_daily in Dates_daily: file_name = 'P_RFE.v2.0_mm-day-1_daily_%s.%02s.%02s.tif' % ( Date_daily.strftime('%Y'), Date_daily.strftime('%m'), Date_daily.strftime('%d')) file_name_daily_path = os.path.join(input_folder_daily, file_name) if os.path.exists(file_name_daily_path): if Date_daily == Dates_daily[i]: Raster_monthly = RC.Open_tiff_array(file_name_daily_path) else: Raster_monthly += RC.Open_tiff_array(file_name_daily_path) else: if Date_daily == Dates_daily[i]: i += 1 geo_out, proj, size_X, size_Y = RC.Open_array_info( file_name_daily_path) file_name = 'P_RFE.v2.0_mm-month-1_monthly_%s.%02s.01.tif' % ( Date.strftime('%Y'), Date.strftime('%m')) file_name_output = os.path.join(output_folder, file_name) DC.Save_as_tiff(file_name_output, Raster_monthly, geo_out, projection="WGS84") if Waitbar == 1: amount += 1 WaitbarConsole.printWaitBar(amount, total_amount, prefix='Progress:', suffix='Complete', length=50)