Beispiel #1
0
def ncf_write_by_varinfo(ncflnm,
                         dimname,
                         dimtype,
                         dimvar,
                         varinfos,
                         dimattr=None):

    dimTypes = dimtype
    dimVars = dimvar
    # print size(dimVars[0])
    # print size(dimVars[1])

    dimNames = dimname

    nf.netCDF_def_dims(ncflnm, dimNames, dimTypes, dimVars, dimattr=dimattr)
    tc = list()
    if (type(tc) == type(varinfos)):
        nvar = len(varinfos)
        for varinfo in varinfos:
            varName = varinfo.name
            varType = varinfo.type
            varData = varinfo.var
            vardimnames = varinfo.dimname
            varattr = varinfo.varattr
            # print 'winfo', varName
            # print shape(varData)
            # print vardimnames
            nf.netCDF_var_write(ncflnm, vardimnames, varName, varType, varData,
                                varattr)
Beispiel #2
0
def ncf_write_cf(ncflnm, diminfos, varinfos, glbattr=None):
    """ generate netcdf file according CF-1 conventions
    diminfo: information of dimension
    varino:  information of variables
    
    """
    print 'I am here'
    print ncflnm
    print 'define dims'
    nf.netCDF_def_dims_cf(ncflnm, diminfos, glbattr=glbattr)
    print 'after define dims'

    tc = list()
    if (type(tc) == type(varinfos)):
        nvar = len(varinfos)
        for varinfo in varinfos:
            varName = varinfo.name
            varType = varinfo.type
            varData = varinfo.var
            vardimnames = varinfo.dimname
            varattr = varinfo.varattr
            print 'winfo', varName
            print shape(varData)
            print vardimnames

            nf.netCDF_var_write(ncflnm, vardimnames, varName, varType, varData,
                                varattr)
Beispiel #3
0
def ncf_write(ncflnm, dimname, dimtype, dimvar, varnames, vartypes, vars):
    dimTypes = dimtype
    dimVars = dimvar
    dimNames = dimname
    nf.netCDF_def_dims(ncflnm, dimNames, dimTypes, dimVars)
    tc = list()
    if (type(tc) == type(varnames)):
        nvar = len(varnames)
        for ivar in range(nvar):
            varName = varnames[ivar]
            varType = vartypes[ivar]
            varData = vars[ivar]

            print varName, size(varData), size(dimvar)
            nf.netCDF_var_write(ncflnm, dimNames, varName, varType, varData)
    def save_to_netcdf(self, gpfile, gpname):
        """ dump the data to the netcdf file 
        """
        import netCDF_gen as nf

        dimTypes = list()
        dimVars = list()
        dimNames = list()
        for ax in self.axis_set:
            dimTypes.append('f')
            axvar = array(ax[:])
            axname = ax.getprop('name')
            dimNames.append(axname)
            dimVars.append(axvar)

        nf.netCDF_def_dims(gpfile, dimNames, dimTypes, dimVars)

        varName = gpname
        varType = 'f'

        varData = self.gpdict[gpname]

        nf.netCDF_var_write(gpfile, dimNames, varName, varType, varData)
Beispiel #5
0
    lwi=obs.obs_lwi
    
    
    dimTypes=['f']
    dimVars=[otime]    
    dimNames=['time']
    nf.netCDF_def_dims(ncflnm,dimNames,dimTypes, dimVars)

    # lon
    
    varName='lon'
    varType='f'
     
    varData=olon

    nf.netCDF_var_write(ncflnm,dimNames,varName, varType, varData)
    
    # lat
    
    varName='lat'
    varType='f'
     
    varData=olat

    nf.netCDF_var_write(ncflnm,dimNames,varName, varType, varData)

    # cflag
    
    varName='cloud'
    varType='i'