def hat_avg_scalar(self, data, numfile=0): rho = self.IO.load_from('data', 'RHO', numfile) print(gmp.switch) varshape = np.shape(rho) rho = self.nfo_merge(rho) rho_bar = self.IO.load_from('newdata', 'RHO_BAR', numfile) X = self.IO.load_from('data', data, numfile) X = self.nfo_merge(X) X_hat = self.create_array(varshape) math.hat_scalar(X, rho, rho_bar, self.c_area, self.c_mem_idx, X_hat) return X_hat
def compute_T(self, filenum=0): rho = self.IO.load_from('data', 'RHO', filenum) varshape = list(np.shape(rho)) rho = self.nfo_merge(rho) rho_bar = self.IO.load_from('newdata', 'RHO_BAR') theta = self.IO.load_from('data', 'THETA_V', filenum) exner = self.IO.load_from('data', 'EXNER', filenum) T = self.create_array(varshape) print('computing the true Temperature values ...') phys.thet_ex_to_T(theta, exner, T) self.IO.write_to('data', T, name='T', attrs = { 'long_name': 'Temperature', 'coordinates': 'vlat vlon', '_FillValue': float('nan'), 'grid_type' : 'unstructured' }, filenum=filenum ) del theta, exner T = self.nfo_merge(T) T_hat = self.create_array(varshape) print('computing the density weighted coarse Temperature values ...') math.hat_scalar( T, rho, rho_bar, self.c_area, self.c_mem_idx, T_hat ) self.IO.write_to('data', T_hat, name='T_HAT', attrs={ 'long_name': 'density weighted Temperature', 'coordinates': 'vlat vlon', '_FillValue' : float('nan'), 'grid_type' : 'unstructured' }, filenum=filenum )
def test_hat_scalar_par(self): gmp.set_parallel_proc(True) return_array[:] = np.zeros((1, 3, 3)) math.hat_scalar(test_array, rho, [rho_bar], [total_area], c_mem_idx, return_array) self.assertTrue(([np.ones((3, 3))] == return_array).all())
def prepare_pres(self, filenum=0): rho = self.IO.load_from('data', 'RHO', filenum) varshape = list(np.shape(rho)) rho = self.nfo_merge(rho) rho_bar = self.IO.load_from('newdata', 'RHO_BAR') theta = self.IO.load_from('data', 'THETA_V', filenum) theta = self.nfo_merge(theta) theta_hat = self.create_array(varshape) print('computing the density weighted coarse theta values ...') math.hat_scalar( theta, rho, rho_bar, self.c_area, self.c_mem_idx, theta_hat ) self.IO.write_to('data', theta_hat, name='THETA_HAT', attrs={ 'long_name': 'density weighted theta_v', 'coordinates': 'vlat vlon', '_FillValue' : float('nan'), 'grid_type' : 'unstructured' }, filenum=filenum ) exner = self.IO.load_from('data', 'EXNER', filenum) exner = self.nfo_merge(exner) exner_hat = self.create_array(varshape) print('computing the density weighted coarse exner values ...') math.hat_scalar( exner, rho, rho_bar, self.c_area, self.c_mem_idx, exner_hat ) del exner self.IO.write_to('data', exner_hat, name='EXNER_HAT', attrs={ 'long_name': 'density weighted exner pressure', 'coordinates': 'vlat vlon', '_FillValue' : float('nan'), 'grid_type' : 'unstructured' }, filenum=filenum ) print('computing the coarse exner gradients') exner_gradient = self.x_hat_gradients(exner_hat) del exner_hat self.IO.write_to('data', exner_gradient[:,0,:, ], name='DEXX', attrs={ 'long_name': 'x grad of density weighted exner pressure', 'coordinates': 'vlat vlon', '_FillValue' : float('nan'), 'grid_type' : 'unstructured' }, filenum=filenum ) self.IO.write_to('data', exner_gradient[:,1,:, ], name='DEXY', attrs={ 'long_name': 'y grad of density weighted exner pressure', 'coordinates': 'vlat vlon', '_FillValue' : float('nan'), 'grid_type' : 'unstructured' }, filenum=filenum ) del exner_gradient