当前位置: 首页>>代码示例>>Python>>正文


Python OCO_Matrix.file_id方法代码示例

本文整理汇总了Python中OCO_Matrix.OCO_Matrix.file_id方法的典型用法代码示例。如果您正苦于以下问题:Python OCO_Matrix.file_id方法的具体用法?Python OCO_Matrix.file_id怎么用?Python OCO_Matrix.file_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OCO_Matrix.OCO_Matrix的用法示例。


在下文中一共展示了OCO_Matrix.file_id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: write_xco2_file

# 需要导入模块: from OCO_Matrix import OCO_Matrix [as 别名]
# 或者: from OCO_Matrix.OCO_Matrix import file_id [as 别名]
def write_xco2_file(log_sounding_dict, xco2_filename):
    xco2_fileobj = OCO_Matrix()
    xco2_fileobj.file_id = 'True xco2 from orbit simulator'
    xco2_fileobj.labels = [XCO2_LABEL_NAME]
    xco2_fileobj.data = numpy.zeros((1,1), dtype=float)
    xco2_fileobj.data[0,0] = log_sounding_dict[XCO2_COL_NAME]
    xco2_fileobj.write(xco2_filename)
开发者ID:E-LLP,项目名称:RtRetrievalFramework,代码行数:9,代码来源:extract_orbit_sim_data.py

示例2: create_mean_psurf

# 需要导入模块: from OCO_Matrix import OCO_Matrix [as 别名]
# 或者: from OCO_Matrix.OCO_Matrix import file_id [as 别名]
def create_mean_psurf(runlog_file, psurf_file):

    print 'runlog_file = ', runlog_file
    print 'psurf_file = ', psurf_file
    
    runlog_fobj = open(runlog_file, "r")

    header_cols = runlog_fobj.readline().split()

    pout_col = header_cols.index('pout')

    pouts = []
    for runlog_line in runlog_fobj.readlines():
        runlog_parts = runlog_line.split()
        pouts.append(float(runlog_parts[pout_col]))
        
    runlog_fobj.close()
    
    avg_psurf = mean(pouts) * 1e2

    out_mat_obj = OCO_Matrix()
    out_mat_obj.file_id = "Mean surface pressure from runlog file: %s" % runlog_file
    out_mat_obj.labels = ['LEVEL', 'PSURF']
    out_mat_obj.data = ones((1, 2), dtype=float)
    out_mat_obj.data[0, 1] = avg_psurf
    out_mat_obj.write(psurf_file)
开发者ID:E-LLP,项目名称:RtRetrievalFramework,代码行数:28,代码来源:create_runlog_mean_psurf.py

示例3: write_soundinginfo_file

# 需要导入模块: from OCO_Matrix import OCO_Matrix [as 别名]
# 或者: from OCO_Matrix.OCO_Matrix import file_id [as 别名]
def write_soundinginfo_file(hdf_sounding_dict, sounding_info_filename, sounding_id):
    sounding_info_fileobj = OCO_Matrix()
    sounding_info_fileobj.file_id = 'Sounding info from orbit simulator for sounding id: %s' % sounding_id

    sounding_info_fileobj.header = hdf_sounding_dict
    
    sounding_info_fileobj.header['sounding_id'] = sounding_id

    sounding_info_fileobj.write(sounding_info_filename)
开发者ID:E-LLP,项目名称:RtRetrievalFramework,代码行数:11,代码来源:extract_orbit_sim_data.py

示例4: extract_ils_from_hdf

# 需要导入模块: from OCO_Matrix import OCO_Matrix [as 别名]
# 或者: from OCO_Matrix.OCO_Matrix import file_id [as 别名]
def extract_ils_from_hdf(hdf_file, output_dir, reverse=False):
    print 'Opening HDF file: %s' % hdf_file
    with contextlib.closing(h5py.File(hdf_file, 'r')) as hdf_obj:

        reported_soundings = []
        for snd_idx, rep_val in enumerate(hdf_obj['Metadata']['ReportedSoundings']):
            if rep_val > 0:
                reported_soundings.append( snd_idx + 1 )

        ils_delta_lambda      = hdf_obj['InstrumentHeader']['ils_delta_lambda']
        ils_relative_response = hdf_obj['InstrumentHeader']['ils_relative_response']

        num_bands          = ils_delta_lambda.shape[0]
        num_ils_parameters = ils_delta_lambda.shape[2]
        num_ils_wndepend   = ils_delta_lambda.shape[3]

        labels = [ 'ILS_PIXELS' ]
        for band_num in range(1, num_bands+1):
            labels.append('ILS_DELTA_LAMBDA_%d' % band_num)
            labels.append('ILS_RESPONSE_%d' % band_num)

        for snd_idx, sounding_id in enumerate(reported_soundings):
            output_filename = os.path.join(output_dir, 'ils_%d.dat' % sounding_id)
            print 'Extracting data for sounding %d into %s' % (sounding_id, output_filename)

            ils_file = OCO_Matrix()
            ils_file.data = numpy.zeros((num_ils_parameters * num_ils_wndepend, num_bands*2+1), dtype=float)

            row_beg = 0
            for color_index in range(num_ils_parameters):
                print 'Extracting color %d' % (color_index+1)
                row_end = row_beg+num_ils_wndepend
                ils_file.data[row_beg:row_end, 0] = color_index + 1

                for band_idx, col_idx in zip(range(num_bands), range(1,1+2*num_bands,2)):
                    ils_file.data[row_beg:row_end, col_idx]   = ils_delta_lambda[band_idx, snd_idx, color_index, :]

                    if reverse:
                        ils_file.data[row_beg:row_end, col_idx+1] = ils_relative_response[band_idx, snd_idx, color_index, :][::-1]
                    else:
                        ils_file.data[row_beg:row_end, col_idx+1] = ils_relative_response[band_idx, snd_idx, color_index, :]

                row_beg = row_end


            ils_file.file_id = 'Instrument Line Shape parameters for sounding posistion %d' % sounding_id

            ils_file.labels = labels

            ils_file.header['function_type'] = 'TABLE'
            ils_file.header['interpolation'] = '100 100 100'
            ils_file.header['num_ils_parameters'] = num_ils_parameters
            ils_file.header['num_ils_wndepend']   = num_ils_wndepend

            print 'Writing to %s' % output_filename
            ils_file.write(output_filename, verbose=True)
开发者ID:E-LLP,项目名称:RtRetrievalFramework,代码行数:58,代码来源:extract_ils_from_hdf.py

示例5: write_albedo_file

# 需要导入模块: from OCO_Matrix import OCO_Matrix [as 别名]
# 或者: from OCO_Matrix.OCO_Matrix import file_id [as 别名]
def write_albedo_file(output_file, albedo_data, header_values=None):
   albedo_obj = OCO_Matrix()
   if header_values != None:
      albedo_obj.header.update(header_values)

   albedo_obj.header['center_wavelengths'] = ' '.join([str(wl) for wl in ALBEDO_CENTER_WAVELENGTHS])
   albedo_obj.labels = [ ALBEDO_COL_TMPL % (idx+1) for idx in range(albedo_data.shape[1]) ]
   albedo_obj.data = albedo_data
   albedo_obj.file_id = 'Surface albedo data'
   albedo_obj.write(output_file)
开发者ID:E-LLP,项目名称:RtRetrievalFramework,代码行数:12,代码来源:create_surface_apriori.py

示例6: write_total_aod_file

# 需要导入模块: from OCO_Matrix import OCO_Matrix [as 别名]
# 或者: from OCO_Matrix.OCO_Matrix import file_id [as 别名]
def write_total_aod_file(log_sounding_dict, aod_filename):
    # make aerosol_od_<sounding_id>.dat
    
    aod_fileobj = OCO_Matrix()
    aod_fileobj.file_id = 'True aerosol optical depth from orbit simulator'
    aod_fileobj.labels = AOD_LABEL_NAMES
    aod_fileobj.data = numpy.zeros((1,len(AOD_COL_NAMES)), dtype=float)

    for out_idx, aer_col_name in enumerate(AOD_COL_NAMES):
        aod_fileobj.data[0,out_idx] = log_sounding_dict[aer_col_name]

    aod_fileobj.write(aod_filename)
开发者ID:E-LLP,项目名称:RtRetrievalFramework,代码行数:14,代码来源:extract_orbit_sim_data.py

示例7: write_psurf_file

# 需要导入模块: from OCO_Matrix import OCO_Matrix [as 别名]
# 或者: from OCO_Matrix.OCO_Matrix import file_id [as 别名]
def write_psurf_file(psurf, out_filename):

    out_psurf_data = numpy.zeros((1, 1), dtype=float)

    out_psurf_data[0, 0] = psurf

    out_mat_obj = OCO_Matrix()
    out_mat_obj.file_id = 'True surface pressure from orbit simulator'
    out_mat_obj.data = out_psurf_data
    out_mat_obj.labels = ['PSURF']
    out_mat_obj.units =  ['Pa']

    out_mat_obj.write(out_filename)
开发者ID:E-LLP,项目名称:RtRetrievalFramework,代码行数:15,代码来源:extract_orbit_sim_data.py

示例8: Process_File

# 需要导入模块: from OCO_Matrix import OCO_Matrix [as 别名]
# 或者: from OCO_Matrix.OCO_Matrix import file_id [as 别名]
def Process_File(source, destination, fileKeywords, moduleSections, valuesDict, mapDict):

    if len(moduleSections) > 1:
        raise RuntimeError("Only one input file config set per file")

    if str(source) == str(destination):
        raise ValueError("source and dest filenames must be different. will not overwrite source file")

    spectrum_file = Apply_Template(moduleSections[0].Get_Keyword_Value("spectrum_file"), valuesDict, mapDict=mapDict)

    if type(source) is str and not os.path.exists(source):
        raise IOError("Runlog file %s does not exist" % source)

    base_spec_name = os.path.basename(spectrum_file)

    # Use grep because its faster than doing it outself
    matched_line = None
    if type(source) == str:
        grep_cmd = "grep -E " + base_spec_name + " " + source
        matched_line = os.popen(grep_cmd).readline()

    elif hasattr(source, "read"):
        for curr_line in source.readlines():
            if re.search(base_spec_name, curr_line):
                matched_line = curr_line
                break
    else:
        raise Exception("Unsupported object: %s" % source)

    if matched_line == None or len(matched_line) == 0:
        raise IOError("Could not find spectrum name: %s in run log file: %s" % (base_spec_name, source))

    try:
        matched_columns = matched_line.split()
        psurf_val = float(matched_columns[pout_col_idx]) * convert_factor
    except:
        raise ValueError(
            'Failed to parse psurf value from: "%s" from runlog line: %s'
            % (matched_columns[pout_col_idx], matched_line)
        )

    out_obj = OCO_Matrix()

    out_obj.data = numpy.zeros((1, 1), dtype=float)
    out_obj.data[0, 0] = psurf_val

    out_obj.file_id = "psurf value extracted for spectrum named: %s from runlog file: %s" % (base_spec_name, source)
    out_obj.labels = ["PSURF"]

    out_obj.write(destination)
开发者ID:nasa,项目名称:RtRetrievalFramework,代码行数:52,代码来源:psurf_from_runlog.py

示例9: write_windspeed_file

# 需要导入模块: from OCO_Matrix import OCO_Matrix [as 别名]
# 或者: from OCO_Matrix.OCO_Matrix import file_id [as 别名]
def write_windspeed_file(sounding_data, out_filename):

    out_windspeed_data = numpy.zeros((1, 1), dtype=float)

    ws_data = sounding_data['surface_windspeed']
    if hasattr(ws_data, '__iter__'):
        out_windspeed_data[0, 0] = ws_data[0]
    else:
        out_windspeed_data[0, 0] = ws_data
        
    out_mat_obj = OCO_Matrix()
    out_mat_obj.file_id = 'True windspeed from orbit simulator'
    out_mat_obj.data = out_windspeed_data
    out_mat_obj.labels = ['WINDSPEED']
    out_mat_obj.units =  ['m/s']

    out_mat_obj.write(out_filename)
开发者ID:E-LLP,项目名称:RtRetrievalFramework,代码行数:19,代码来源:extract_orbit_sim_data.py

示例10: write_windspeed_file

# 需要导入模块: from OCO_Matrix import OCO_Matrix [as 别名]
# 或者: from OCO_Matrix.OCO_Matrix import file_id [as 别名]
def write_windspeed_file(sounding_id, apriori_out_dir, ws_value, header_values=None, windspeed_f=False):

   windspeed_obj = OCO_Matrix()

   windspeed_obj.data = numpy.zeros((1,1), dtype=float)
   windspeed_obj.data[:,:] = ws_value
   windspeed_obj.labels = WINDSPEED_LABELS
   windspeed_obj.units  = WINDSPEED_UNITS
   windspeed_obj.file_id = 'Windspeed for sounding: %s' % sounding_id

   if header_values != None:
      windspeed_obj.header.update(header_values)

   if windspeed_f:
      windspeed_obj.header['Windspeed_F'] = True
      windspeed_obj.write(WINDSPEED_F_FILE_TMPL % (apriori_out_dir, sounding_id))
   else:
      windspeed_obj.write(WINDSPEED_FILE_TMPL % (apriori_out_dir, sounding_id))
开发者ID:E-LLP,项目名称:RtRetrievalFramework,代码行数:20,代码来源:create_surface_apriori.py

示例11: create_simple_cov

# 需要导入模块: from OCO_Matrix import OCO_Matrix [as 别名]
# 或者: from OCO_Matrix.OCO_Matrix import file_id [as 别名]
def create_simple_cov(input_file, output_file, scaling, columns):
    logger = logging.getLogger(os.path.basename(__file__))

    # Load source file
    src_obj = OCO_Matrix(input_file)

    scaling = [float(v) for v in scaling.split(',')]
    if len(scaling) < src_obj.dims[0]:
        last_val = scaling[len(scaling)-1]
        [ scaling.append(last_val) for nada in range(src_obj.dims[0] - len(scaling)) ]

    try:
        columns = index_range_list(columns, max_value=src_obj.dims[1])
    except:
        if not type(columns) is ListType:
            col_name_list = [columns]
        else:
            col_name_list = columns

        columns = []
        for curr_name in col_name_list:
            if curr_name.lower() not in src_obj.labels_lower:
                raise IOError('Column named %s not found in file: %s' % (curr_name, input_file))
            columns.append( src_obj.labels_lower.index(curr_name.lower()) )
                                    
    logger.info('cols = ', columns)

    num_diags = len(columns) * src_obj.dims[0]
    logger.info('num_diags = ', num_diags)
    dst_data = numpy.zeros((num_diags, num_diags), dtype=float)

    diag_index = 0
    for col_index in columns:
        for row_index in range(src_obj.dims[0]):
            #print '%d, %d => %d, %d' % (row_index, col_index, diag_index, diag_index)
            dst_data[diag_index, diag_index] = (src_obj.data[row_index, col_index] * scaling[row_index])**2
            diag_index += 1

    logger.info('Writing: %s' % input_file)
    src_obj.file_id = 'Simple Covariance Created from "%s", scaling: "%s"' % (input_file, ', '.join([str(sc) for sc in scaling]))
    src_obj.labels = []
    src_obj.data = dst_data
    src_obj.units = []
    src_obj.write(output_file, auto_size_cols=False, verbose=True)
开发者ID:E-LLP,项目名称:RtRetrievalFramework,代码行数:46,代码来源:create_simple_cov.py

示例12: write_radcnv_file

# 需要导入模块: from OCO_Matrix import OCO_Matrix [as 别名]
# 或者: from OCO_Matrix.OCO_Matrix import file_id [as 别名]
def write_radcnv_file(output_filename, column_names, sheet, input_rows, input_cols, scaling=1.0):
    file_obj = OCO_Matrix()
    file_obj.labels = column_names
    file_obj.file_id = FILE_ID

    file_obj.data = numpy.zeros((len(input_rows), len(input_cols)), dtype=numpy.chararray)
    out_row_idx = 0
    for in_row_idx, out_row_idx in zip(input_rows, range(len(input_rows)) ):
        for in_col_idx, out_col_idx in zip(input_cols, range(len(input_cols)) ):
            cell_data = get_cell_data(sheet, in_row_idx, in_col_idx)
            if cell_data != None and column_names[out_col_idx] != WAVENUMBER_COLUMN_NAME:
                try:
                    cell_data *= scaling
                except TypeError as e:
                    raise TypeError('%s: cell_data = "%s", scaling = "%s" at row: %d column %d' % (e, cell_data, scaling, in_row_idx, in_col_idx))
            file_obj.data[out_row_idx, out_col_idx] = cell_data

    print 'Writing output filename: %s' % output_filename
    file_obj.write(output_filename)
开发者ID:E-LLP,项目名称:RtRetrievalFramework,代码行数:21,代码来源:convert_gosat_radcnv.py

示例13: extract_soundinginfo_file

# 需要导入模块: from OCO_Matrix import OCO_Matrix [as 别名]
# 或者: from OCO_Matrix.OCO_Matrix import file_id [as 别名]
def extract_soundinginfo_file(inp_fileobj, output_filename):
    soundinginfo_sect = inp_fileobj.Get_Section("SOUNDING_INFO")
    soundinginfo_file = get_inp_file_path(inp_fileobj, soundinginfo_sect[0].Get_Keyword_Value("soundinginfo_file"))

    print "%s -> %s" % (soundinginfo_file, output_filename)

    # Handle converting sounding info files without a HEADER block
    si_fileobj = L2_Input.Input_File(soundinginfo_file)

    header_section = si_fileobj.Get_Section("HEADER")
    if len(header_section) > 0:
        key_dict = header_section[0].Get_Keywords_Dict()
    else:
        key_dict = si_fileobj.Get_Keywords_Dict()

    output_matobj = OCO_Matrix()
    output_matobj.header.update(key_dict)
    output_matobj.file_id = "Sounding Information"
    output_matobj.write(output_filename)

    write_source_into_header(output_filename, soundinginfo_file)
开发者ID:E-LLP,项目名称:RtRetrievalFramework,代码行数:23,代码来源:create_dataset_from_inp.py

示例14: write_spectra_files

# 需要导入模块: from OCO_Matrix import OCO_Matrix [as 别名]
# 或者: from OCO_Matrix.OCO_Matrix import file_id [as 别名]
def write_spectra_files(output_dir, ids, data):
    for curr_id, curr_data in zip(ids, data):
        out_filename = '%s/%s.dat' % (output_dir, curr_id)
        used_data = []
        
        out_obj = OCO_Matrix()
        out_obj.labels = FILE_LABELS
        out_obj.units  = FILE_UNITS
        out_obj.file_id = FILE_ID_TMPL % (curr_id)

        out_obj.data = numpy.zeros((curr_data['Num_Points'], len(FILE_LABELS)), dtype=float)
        used_data.append('Num_Points')
        for column_idx, column_name in enumerate(FILE_LABELS):
            if curr_data.has_key(column_name):
                out_obj.data[:, column_idx] = curr_data[column_name]
                used_data.append(column_name)

        header_dict = copy.copy(curr_data)
        header_dict.update(HEADER_FILL_VALUES)
        for data_name, data_values in header_dict.items():
            if data_name in used_data:
                continue

            out_name = translate_header_name(data_name)

            try:
                if len(data_values.shape) == 0:
                    out_obj.header[out_name] = str(data_values)
                else:
                    out_obj.header[out_name] = ' '.join([ str(item) for item in iter(data_values)])
            except:
                try:
                    out_obj.header[out_name] = str(data_values)
                except:
                    print >>sys.stderr, 'Barfed on parsing %s with values: %s for header of file %s' % (data_name, data_values, out_filename)

        print 'Writing: %s' % out_filename
        out_obj.write(out_filename)
开发者ID:E-LLP,项目名称:RtRetrievalFramework,代码行数:40,代码来源:extract_gosat_spectra.py

示例15: write_atmosphere_file

# 需要导入模块: from OCO_Matrix import OCO_Matrix [as 别名]
# 或者: from OCO_Matrix.OCO_Matrix import file_id [as 别名]
def write_atmosphere_file(sounding_data, out_filename, pressure_in, pressure_out, profile_mass_densities=False):
    gas_names = sounding_data['gas_names']
    num_cols = len(gas_names) + 2
    
    out_atm_data = numpy.zeros((len(pressure_out), num_cols), dtype=float)

    out_atm_data[:, 0] = resample_profile(pressure_in, pressure_in, pressure_out, log_data=True, extrapolate=True)               
    out_atm_data[:, 1] = resample_profile(pressure_in, sounding_data['temperature'][LEV_BEG:], pressure_out, log_data=False, extrapolate=True)

    for gas_idx in range(len(gas_names)):
        curr_gas = sounding_data['gas_names'][gas_idx]

        # Ensure data is a numpy array 
        source_data = numpy.array(sounding_data['gas_mix_ratio'][curr_gas]) 

        if profile_mass_densities and curr_gas.find("AIR") != 0:
            # Convert H2O from mol/m^2 to VMR
            # The profiles in the Simulation structure are layer mass densities in mol/m^2
            # They are converted to volume mixing ratios by dividing by the mass density of dry air, also in mol/m^2
            source_data = source_data/sounding_data['gas_mix_ratio'][DRY_AIR_NAME]

        elif curr_gas == 'H2O':
            # Convert H2O from specific humidity%
            source_data = source_data/(1.0 - source_data)/H2O_CONVERT_EPSILON
                
        out_atm_data[:, gas_idx+2] = resample_profile(pressure_in, source_data[LEV_BEG:], pressure_out, log_data=True, extrapolate=False)
        

    out_mat_obj = OCO_Matrix()
    out_mat_obj.file_id = 'True atmospheric profiles from orbit simulator'
    out_mat_obj.data = out_atm_data
    out_mat_obj.labels = ['Pressure', 'T'] + list(gas_names)
    out_mat_obj.units =  ['Pa', 'K'] + [ 'VMR' for x in range(len(gas_names)) ]

    out_mat_obj.write(out_filename)

    return out_atm_data
开发者ID:E-LLP,项目名称:RtRetrievalFramework,代码行数:39,代码来源:extract_orbit_sim_data.py


注:本文中的OCO_Matrix.OCO_Matrix.file_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。