예제 #1
0
latnrs = np.arange(7,114)
lonnrs = np.arange(0,240)

# the lake numbers below belong to the ERA-Interim data on 1.5 degree starting at Northern latitude 79.5 and longitude -180
lake_mask_1 = np.array([9,9,9,12,12,21,21,22,22,23,24,25,23,23,25,25,53,54,61,23,24,23,24,25,27,22,23,24,25,26,27,28,22,25,26,27,28,23,23,12,18])
lake_mask_2 = np.array([120+19,120+40,120+41,120+43,120+44,120+61,120+62,120+62,120+63,120+62,120+62,120+62,120+65,120+66,120+65,120+66,142-120,142-120,143-120,152-120,152-120,153-120,153-120,153-120,153-120,154-120,154-120,154-120,154-120,154-120,154-120,154-120,155-120,155-120,155-120,155-120,155-120,159-120,160-120,144-120,120+55])
lake_mask = np.transpose(np.vstack((lake_mask_1,lake_mask_2))) #recreate the arrays of the matlab model

# obtain the constants

invariant_data = 'input/lsm.nc' #invariants
interdata_folder = 'interdata'
input_folder = 'input'


latitude,longitude,lsm,g,density_water,timestep,A_gridcell,L_N_gridcell,L_S_gridcell,L_EW_gridcell,gridcell = getconstants(latnrs,lonnrs,lake_mask,invariant_data)

# BEGIN OF INPUT 2 (FILL THIS IN)
Region = lsm
Kvf = 3 # vertical dispersion factor (advection only is 0, dispersion the same size of the advective flux is 1, for stability don't make this more than 3)
timetracking = 1 # 0 for not tracking time and 1 for tracking time
veryfirstrun = 1 # type '1' if no run has been done before from which can be continued, otherwise type '0'


#END OF INPUT

#%% Runtime & Results

start1 = timer()

# The two lines below create empty arrays for first runs/initial values are zero. 
import matplotlib as cm
import os
from timeit import default_timer as timer
import calendar
import datetime
#%% BEGIN OF INPUT (FILL THIS IN)
years = np.arange(1980, 2019)  #fill in the years
yearpart = np.arange(0, 366)  # for a full (leap)year fill in (365,-1,-1)
# Manage the extent of your dataset (FILL THIS IN)
# Define the latitude and longitude cell numbers to consider and corresponding lakes that should be considered part of the land
latnrs = np.arange(196, 433)  # 43N - -10N
lonnrs = np.arange(880, 1400)  #40E - 180E

# obtain the constants
invariant_data = r'/public/home/mzxiao/ERA5/landseamask.nc'  #invariants
latitude, longitude, lsm, g, density_water, A_gridcell, L_N_gridcell, L_S_gridcell, L_EW_gridcell = getconstants(
    latnrs, lonnrs, invariant_data)
A_gridcell2D = np.tile(A_gridcell, len(longitude))

# BEGIN OF INPUT 2 (FILL THIS IN)
timetracking = 0  # 0 for not tracking time and 1 for tracking time
# Region = lsm[latnrs,:][:,lonnrs]
# The focus Region
Region_s = np.zeros(np.shape(lsm))
# The selected region
Region_s[265:274, 1169:1180] = 1  # N:21.75-23.75 E: 112.25-114.75
lsm_s = lsm * Region_s
Region = lsm_s[latnrs, :][:, lonnrs]
Region[Region > 0.8] = 1  # Change the lake also as land, which is not in lsm

interdata_folder = r'/public/home/mzxiao/WAM2layersPython_modify/interdata'
sub_interdata_folder = os.path.join(interdata_folder, 'continental_backward')
예제 #3
0
lake_mask = np.transpose(np.vstack(
    (lake_mask_1, lake_mask_2)))  #recreate the arrays of the matlab model

#END OF INPUT

# Datapaths (FILL THIS IN)
invariant_data = 'input/lsm.nc'  #invariants
interdata_folder = 'interdata'
input_folder = 'input'

start1 = timer()

# obtain the constants
latitude, longitude, lsm, g, density_water, timestep, A_gridcell, \
    L_N_gridcell, L_S_gridcell, L_EW_gridcell, gridcell = \
    getconstants(latnrs, lonnrs, lake_mask, invariant_data)

# loop through the years
for yearnumber in years:

    ly = int(calendar.isleap(yearnumber))
    final_time = 364 + ly  # number of parts-1 to divide a year in

    for a in yearpart:  # a > 365 (366th index) and not a leapyear
        start = timer()

        datapath = data_path(yearnumber, a, input_folder, interdata_folder)

        if a > final_time:
            pass
            # do nothing