[23818] | 1 | #Test Name: SquareShelfSMBGembClim
|
---|
[25836] | 2 | from socket import gethostname
|
---|
| 3 | import sys
|
---|
| 4 |
|
---|
[23818] | 5 | import numpy as np
|
---|
[25836] | 6 |
|
---|
[23818] | 7 | from model import *
|
---|
| 8 | from parameterize import *
|
---|
| 9 | from setflowequation import *
|
---|
[25836] | 10 | from setmask import *
|
---|
| 11 | from SMBgemb import *
|
---|
[23818] | 12 | from solve import *
|
---|
[25836] | 13 | from triangle import *
|
---|
[23818] | 14 |
|
---|
[23858] | 15 | md = triangle(model(), '../Exp/Square.exp', 350000.)
|
---|
[23818] | 16 | md = setmask(md, 'all', '')
|
---|
| 17 | md = parameterize(md, '../Par/SquareShelf.py')
|
---|
| 18 | md = setflowequation(md, 'SSA', 'all')
|
---|
| 19 | md.materials.rho_ice = 910
|
---|
| 20 | md.cluster = generic('name', gethostname(), 'np', 3)
|
---|
| 21 |
|
---|
| 22 | #Use of Gemb method for SMB computation
|
---|
[25836] | 23 | md.smb = SMBgemb(md.mesh, md.geometry)
|
---|
| 24 | md.smb.dsnowIdx = 4
|
---|
[27232] | 25 | md.smb.swIdx = 1
|
---|
| 26 | md.smb.tcIdx = 2
|
---|
[23818] | 27 |
|
---|
| 28 | #load hourly surface forcing date from 1979 to 2009:
|
---|
| 29 | if sys.version_info.major == 2:
|
---|
[24238] | 30 | inputs = np.load('../Data/gemb_input.npy', allow_pickle=True).item()
|
---|
[23818] | 31 | else:
|
---|
[24238] | 32 | inputs = np.load('../Data/gemb_input.npy', allow_pickle=True, encoding='bytes').item()
|
---|
[23818] | 33 |
|
---|
| 34 | #setup the inputs:
|
---|
| 35 | md.smb.Ta = np.append(np.tile(np.conjugate(inputs[b'Ta0']), (md.mesh.numberofelements, 1)), np.conjugate([inputs[b'dateN']]), axis=0)
|
---|
| 36 | md.smb.V = np.append(np.tile(np.conjugate(inputs[b'V0']), (md.mesh.numberofelements, 1)), np.conjugate([inputs[b'dateN']]), axis=0)
|
---|
| 37 | md.smb.dswrf = np.append(np.tile(np.conjugate(inputs[b'dsw0']), (md.mesh.numberofelements, 1)), np.conjugate([inputs[b'dateN']]), axis=0)
|
---|
| 38 | md.smb.dlwrf = np.append(np.tile(np.conjugate(inputs[b'dlw0']), (md.mesh.numberofelements, 1)), np.conjugate([inputs[b'dateN']]), axis=0)
|
---|
| 39 | md.smb.P = np.append(np.tile(np.conjugate(inputs[b'P0']), (md.mesh.numberofelements, 1)), np.conjugate([inputs[b'dateN']]), axis=0)
|
---|
| 40 | md.smb.eAir = np.append(np.tile(np.conjugate(inputs[b'eAir0']), (md.mesh.numberofelements, 1)), np.conjugate([inputs[b'dateN']]), axis=0)
|
---|
| 41 | md.smb.pAir = np.append(np.tile(np.conjugate(inputs[b'pAir0']), (md.mesh.numberofelements, 1)), np.conjugate([inputs[b'dateN']]), axis=0)
|
---|
| 42 | md.smb.Vz = np.tile(np.conjugate(inputs[b'LP']['Vz']), (md.mesh.numberofelements, 1)).flatten()
|
---|
| 43 | md.smb.Tz = np.tile(np.conjugate(inputs[b'LP']['Tz']), (md.mesh.numberofelements, 1)).flatten()
|
---|
| 44 | md.smb.Tmean = np.tile(np.conjugate(inputs[b'LP']['Tmean']), (md.mesh.numberofelements, 1)).flatten()
|
---|
| 45 | md.smb.C = np.tile(np.conjugate(inputs[b'LP']['C']), (md.mesh.numberofelements, 1)).flatten()
|
---|
| 46 |
|
---|
[24214] | 47 | md.smb.Ta = md.smb.Ta[:, 0:365 * 8]
|
---|
| 48 | md.smb.V = md.smb.V[:, 0:365 * 8]
|
---|
| 49 | md.smb.dswrf = md.smb.dswrf[:, 0:365 * 8]
|
---|
| 50 | md.smb.dlwrf = md.smb.dlwrf[:, 0:365 * 8]
|
---|
| 51 | md.smb.P = md.smb.P[:, 0:365 * 8]
|
---|
| 52 | md.smb.eAir = md.smb.eAir[:, 0:365 * 8]
|
---|
| 53 | md.smb.pAir = md.smb.pAir[:, 0:365 * 8]
|
---|
[23818] | 54 |
|
---|
[26744] | 55 | md.timestepping.cycle_forcing = 1
|
---|
[23818] | 56 |
|
---|
| 57 | #smb settings
|
---|
| 58 | md.smb.requested_outputs = ['SmbDz', 'SmbT', 'SmbD', 'SmbRe', 'SmbGdn', 'SmbGsp', 'SmbEC', 'SmbA', 'SmbMassBalance', 'SmbMAdd', 'SmbDzAdd', 'SmbFAC']
|
---|
| 59 |
|
---|
| 60 | #only run smb core:
|
---|
| 61 | md.transient.isstressbalance = 0
|
---|
| 62 | md.transient.ismasstransport = 0
|
---|
| 63 | md.transient.isthermal = 0
|
---|
| 64 |
|
---|
| 65 | #time stepping:
|
---|
| 66 | md.timestepping.start_time = 1965.6
|
---|
| 67 | md.timestepping.final_time = 1966.6
|
---|
| 68 | md.timestepping.time_step = 1. / 365.0
|
---|
[26744] | 69 | md.timestepping.interp_forcing = 0.
|
---|
[23818] | 70 |
|
---|
| 71 | #Run transient
|
---|
| 72 | md = solve(md, 'Transient')
|
---|
| 73 |
|
---|
[25836] | 74 | nlayers = md.results.TransientSolution[0].SmbT.shape[1]
|
---|
| 75 | for i in range(1, len(md.results.TransientSolution)):
|
---|
[27035] | 76 | nlayers = np.minimum(md.results.TransientSolution[i].SmbT.shape[1], nlayers)
|
---|
[25836] | 77 |
|
---|
[23818] | 78 | #Fields and tolerances to track changes
|
---|
[27035] | 79 | field_names = ['Layers', 'SmbDz1', 'SmbT1', 'SmbD1', 'SmbRe1', 'SmbGdn1', 'SmbGsp1', 'SmbA1', 'SmbEC1', 'SmbMassBalance1', 'SmbMAdd1', 'SmbDzAdd1', 'SmbFAC1',
|
---|
[24214] | 80 | 'SmbDz2', 'SmbT2', 'SmbD2', 'SmbRe2', 'SmbGdn2', 'SmbGsp2', 'SmbA2', 'SmbEC2', 'SmbMassBalance2', 'SmbMAdd2', 'SmbDzAdd2', 'SmbFAC2',
|
---|
| 81 | 'SmbDz3', 'SmbT3', 'SmbD3', 'SmbRe3', 'SmbGdn3', 'SmbGsp3', 'SmbA3', 'SmbEC3', 'SmbMassBalance3', 'SmbMAdd3', 'SmbDzAdd3', 'SmbFAC3',
|
---|
| 82 | 'SmbDz4', 'SmbT4', 'SmbD4', 'SmbRe4', 'SmbGdn4', 'SmbGsp4', 'SmbA4', 'SmbEC4', 'SmbMassBalance4', 'SmbMAdd4', 'SmbDzAdd4', 'SmbFAC4']
|
---|
[28013] | 83 | field_tolerances = [1e-12, 1e-12, 1e-12, 1e-12, 1e-12, 1e-12, 1e-12, 1e-12, 1e-12, 7e-12, 1e-12, 1e-12, 1e-12,
|
---|
| 84 | 1e-12, 4e-12, 1e-11, 1e-10, 2e-11, 1e-11, 1e-12, 2e-11, 1e-12, 1e-12, 1e-12, 1e-11,
|
---|
| 85 | 1e-12, 4e-12, 2e-12, 2e-11, 4e-11, 1e-11, 1e-12, 4e-11, 4e-11, 1e-12, 1e-12, 1e-11,
|
---|
[27347] | 86 | 1e-11, 1e-11, 4e-11, 4e-11, 2e-11, 4e-11, 1e-12, 3e-12, 1e-10, 1e-12, 1e-12, 2e-11]
|
---|
[25836] | 87 | # Shape is different in python solution (fixed using reshape) which can cause test failure
|
---|
[27232] | 88 | field_values = [nlayers,
|
---|
| 89 | md.results.TransientSolution[0].SmbDz[0, 0:nlayers].reshape(1, -1),
|
---|
| 90 | md.results.TransientSolution[0].SmbT[0, 0:nlayers].reshape(1, -1),
|
---|
| 91 | md.results.TransientSolution[0].SmbD[0, 0:nlayers].reshape(1, -1),
|
---|
| 92 | md.results.TransientSolution[0].SmbRe[0, 0:nlayers].reshape(1, -1),
|
---|
| 93 | md.results.TransientSolution[0].SmbGdn[0, 0:nlayers].reshape(1, -1),
|
---|
| 94 | md.results.TransientSolution[0].SmbGsp[0, 0:nlayers].reshape(1, -1),
|
---|
| 95 | md.results.TransientSolution[0].SmbA[0, 0:nlayers].reshape(1, -1),
|
---|
| 96 | md.results.TransientSolution[0].SmbEC[0],
|
---|
| 97 | md.results.TransientSolution[0].SmbMassBalance[0],
|
---|
| 98 | md.results.TransientSolution[0].SmbMAdd[0],
|
---|
| 99 | md.results.TransientSolution[0].SmbDzAdd[0],
|
---|
| 100 | md.results.TransientSolution[0].SmbFAC[0],
|
---|
| 101 | md.results.TransientSolution[145].SmbDz[0, 0:nlayers].reshape(1, -1),
|
---|
| 102 | md.results.TransientSolution[145].SmbT[0, 0:nlayers].reshape(1, -1),
|
---|
| 103 | md.results.TransientSolution[145].SmbD[0, 0:nlayers].reshape(1, -1),
|
---|
| 104 | md.results.TransientSolution[145].SmbRe[0, 0:nlayers].reshape(1, -1),
|
---|
| 105 | md.results.TransientSolution[145].SmbGdn[0, 0:nlayers].reshape(1, -1),
|
---|
| 106 | md.results.TransientSolution[145].SmbGsp[0, 0:nlayers].reshape(1, -1),
|
---|
| 107 | md.results.TransientSolution[145].SmbA[0, 0:nlayers].reshape(1, -1),
|
---|
| 108 | md.results.TransientSolution[145].SmbEC[0],
|
---|
| 109 | md.results.TransientSolution[145].SmbMassBalance[0],
|
---|
| 110 | md.results.TransientSolution[145].SmbMAdd[0],
|
---|
| 111 | md.results.TransientSolution[145].SmbDzAdd[0],
|
---|
| 112 | md.results.TransientSolution[145].SmbFAC[0],
|
---|
| 113 | md.results.TransientSolution[146].SmbDz[0, 0:nlayers].reshape(1, -1),
|
---|
| 114 | md.results.TransientSolution[146].SmbT[0, 0:nlayers].reshape(1, -1),
|
---|
| 115 | md.results.TransientSolution[146].SmbD[0, 0:nlayers].reshape(1, -1),
|
---|
| 116 | md.results.TransientSolution[146].SmbRe[0, 0:nlayers].reshape(1, -1),
|
---|
| 117 | md.results.TransientSolution[146].SmbGdn[0, 0:nlayers].reshape(1, -1),
|
---|
| 118 | md.results.TransientSolution[146].SmbGsp[0, 0:nlayers].reshape(1, -1),
|
---|
| 119 | md.results.TransientSolution[146].SmbA[0, 0:nlayers].reshape(1, -1),
|
---|
| 120 | md.results.TransientSolution[146].SmbEC[0],
|
---|
| 121 | md.results.TransientSolution[146].SmbMassBalance[0],
|
---|
| 122 | md.results.TransientSolution[146].SmbMAdd[0],
|
---|
| 123 | md.results.TransientSolution[146].SmbDzAdd[0],
|
---|
| 124 | md.results.TransientSolution[146].SmbFAC[0],
|
---|
| 125 | md.results.TransientSolution[-1].SmbDz[0, 0:nlayers].reshape(1, -1),
|
---|
| 126 | md.results.TransientSolution[-1].SmbT[0, 0:nlayers].reshape(1, -1),
|
---|
| 127 | md.results.TransientSolution[-1].SmbD[0, 0:nlayers].reshape(1, -1),
|
---|
| 128 | md.results.TransientSolution[-1].SmbRe[0, 0:nlayers].reshape(1, -1),
|
---|
| 129 | md.results.TransientSolution[-1].SmbGdn[0, 0:nlayers].reshape(1, -1),
|
---|
| 130 | md.results.TransientSolution[-1].SmbGsp[0, 0:nlayers].reshape(1, -1),
|
---|
| 131 | md.results.TransientSolution[-1].SmbA[0, 0:nlayers].reshape(1, -1),
|
---|
| 132 | md.results.TransientSolution[-1].SmbEC[0],
|
---|
| 133 | md.results.TransientSolution[-1].SmbMassBalance[0],
|
---|
| 134 | md.results.TransientSolution[-1].SmbMAdd[0],
|
---|
| 135 | md.results.TransientSolution[-1].SmbDzAdd[0],
|
---|
| 136 | md.results.TransientSolution[-1].SmbFAC[0]]
|
---|