예제 #1
0
    def readMeshMask(self, fname):
        '''
		Reads the meshmask.nc file and extracts the dimensions of the mesh
		as well as the longitude, latitude and nav_lev vectors.

		Requires NetCDF4 and bit.sea to work.

		Inputs:
			> fname: full path to the meshmask.nc file
		'''
        # Load the meshmask (requires bit.sea)
        # This first mask is for loading the cell centered masks
        self._mask = Mask(fname,
                          zlevelsvar="nav_lev",
                          ylevelsmatvar="gphit",
                          xlevelsmatvar="glamt")
        # This mask is for generating the mesh points
        mask = Mask(fname,
                    zlevelsvar="gdepw",
                    ylevelsmatvar="gphif",
                    xlevelsmatvar="glamf")
        # Set variables
        dims = list(mask.shape)  # We need to add the missing points
        dims[0] += 1
        dims[1] += 1
        dims[2] += 1
        # Longitudinal coordinates, add one in the right
        Lon = np.insert(mask.xlevels,
                        0,
                        mask.xlevels[0, :] -
                        (mask.xlevels[0, :] - mask.xlevels[1, :]) / 2.,
                        axis=0)
        Lon = np.insert(Lon,
                        0,
                        Lon[:, 0] - (Lon[:, 0] - Lon[:, 1]) / 2.,
                        axis=1)
        # Latitudinal coordinates, add one in the right
        Lat = np.insert(mask.ylevels,
                        0,
                        mask.ylevels[0, :] +
                        (mask.ylevels[0, :] - mask.ylevels[1, :]) / 2.,
                        axis=0)
        Lat = np.insert(Lat,
                        0,
                        Lat[:, 0] - (Lat[:, 0] - Lat[:, 1]) / 2.,
                        axis=1)
        # Depth coordinates, add the one in the left
        nav_lev = np.append(
            mask.zlevels,
            mask.zlevels[-1] + (mask.zlevels[-1] - mask.zlevels[-2]) / 2.)

        # Return
        return dims, Lon, Lat, nav_lev
예제 #2
0
파일: preproc.py 프로젝트: gbolzon/ogstm
year = int(idate0[0:4])
month = int(idate0[4:6])
day = int(idate0[6:8])
idate1 = timerequestors.Weekly_req(year, month, day)
print idate1

idate2 = timerequestors.Daily_req(year, month, day)
print idate2

# Variable name
VARLIST = ['P_l']  #'N3n','O2o']
read_adjusted = [True]  #,False,False]

# MASK of the domain
TheMask = Mask(
    "/pico/home/usera07ogs/a07ogs00/OPA/V2C/etc/static-data/MED1672_cut/MASK/meshmask.nc"
)
nav_lev = TheMask.zlevels

layer = Layer(0, 200)  #layer of the Float profile????
# new depth from 0 to 200 meters with 1 meter of resolution
NewPres = np.linspace(0, 200, 201)
dimnewpress = len(NewPres)  # data interpolated on the vertical Z

f = open(idate0 + "." + VARLIST[0] + "_arg_mis.dat", "w")  # OUTPUT x il 3DVAR

iniz = "     \n"
f.writelines(iniz)

# LIST of profiles for the selected variable in VARLIST
# in the interval idate1.time_interval in the mediterranean area
예제 #3
0
# generates submask.nc for createGridDA
# to be executed in MODEL/ or where meshmask.nc is

from basins import V0 as OGS
from commons.submask import SubMask
from commons.mask import Mask

TheMask = Mask('meshmask.nc', dzvarname="e3t_0")

for sub in OGS.Pred:
    S = SubMask(sub, maskobject=TheMask)
    S.save_as_netcdf('submask.nc', maskvarname=sub.name)
예제 #4
0
                        default=None,
                        required=True,
                        help=''' Path of maskfile''')

    return parser.parse_args()


args = argument()
nproc = args.mpiprocs
max_proc_i = args.max_proc_i
max_proc_j = args.max_proc_j

from domdec import *
from commons.mask import Mask

TheMask = Mask(args.maskfile, dzvarname="e3t_0")
tmask = TheMask.mask_at_level(0)
jpjglo, jpiglo = tmask.shape

USED_PROCS, COMMUNICATION = candidate_decompositions(tmask, max_proc_i,
                                                     max_proc_j, nproc)

choosen_procs, nproci, nprocj = get_best_decomposition(USED_PROCS,
                                                       COMMUNICATION, nproc,
                                                       jpiglo, jpjglo)

dump_outfile(tmask, choosen_procs, nproci, nprocj)

fig, ax = plot_decomposition(tmask, nproci, nprocj)
fig.set_dpi(150)
outfile = 'domdec_' + str(choosen_procs) + ".png"
예제 #5
0
# Author Giorgio Bolzon
# useful to check differences between 2 directories
# when md5sum cannot be used because of differences in NetCDF files

import numpy as np
from commons.dataextractor import DataExtractor
from commons.mask import Mask
import os, glob

TheMask = Mask(
    '/gpfs/work/IscrC_MEDCOAST_0/test_swp/TEST01/wrkdir/MODEL/meshmask.nc')
DIR1 = "/gpfs/work/IscrC_MEDCOAST_0/test_swp/test_FSA/ogstm/testcase/TEST01/wrkdir/MODEL/AVE_FREQ_2/"
DIR2 = "/gpfs/work/IscrC_MEDCOAST_0/test_swp/TEST01/wrkdir/MODEL/AVE_FREQ_2/"

searchstr = "ave.20000101-12:00:00*nc"
filelist = glob.glob(DIR1 + searchstr)

for file1 in filelist:
    file2 = DIR2 + os.path.basename(file1)
    prefix, datestr, varname, _ = os.path.basename(file2).rsplit(".")
    VAR1 = DataExtractor(TheMask, file1, varname).values
    VAR2 = DataExtractor(TheMask, file2, varname).values
    d = VAR2 - VAR1
    print varname, (d**2).sum()
    if varname == 'O3h': break