예제 #1
0
    def create_variable(self,output,var,years,months):
        #Recover time axis for all files:
        self.obtain_table()

        queryable_file_types_available=list(set(self.table['file_type']).intersection(queryable_file_types))
        if len(self.table['paths'])>0:
            if len(queryable_file_types_available)>0:
                #Open the first file and use its metadata to populate container file:
                first_id=list(self.table['file_type']).index(queryable_file_types_available[0])
                remote_data=remote_netcdf.remote_netCDF(self.table['paths'][first_id],self.table['file_type'][first_id],self.semaphores)
                #try:
                remote_data.open_with_error()
                netcdf_utils.replicate_netcdf_file(output,remote_data.Dataset)
            else:
                remote_data=remote_netcdf.remote_netCDF(self.table['paths'][0],self.table['file_type'][0],self.semaphores)

            #Convert time axis to numbers and find the unique time axis:
            self.unique_time_axis(remote_data.Dataset,years,months)

            self.reduce_paths_ordering()
            #Create time axis in ouptut:
            netcdf_utils.create_time_axis_date(output,remote_data.Dataset,self.time_axis_unique_date)

            self.create(output)
            #if len(queryable_file_types_available)>0:
            self.record_indices(output,remote_data.Dataset,var)
            #except dodsError as e:
            #    e_mod=" This is an uncommon error. It is likely to be FATAL."
            #    print e.value+e_mod
            remote_data.close()

            output.sync()
        return
예제 #2
0
 def replicate(self, output, hdf5=None, check_empty=False):
     #replicate attributes
     netcdf_utils.replicate_netcdf_file(output, self.data_root)
     #replicate and copy variables:
     for var_name in self.data_root.variables.keys():
         netcdf_utils.replicate_and_copy_variable(output,
                                                  self.data_root,
                                                  var_name,
                                                  hdf5=hdf5,
                                                  check_empty=check_empty)
     if 'soft_links' in self.data_root.groups.keys():
         output_grp = netcdf_utils.replicate_group(output, self.data_root,
                                                   'soft_links')
         netcdf_utils.replicate_netcdf_file(
             output_grp, self.data_root.groups['soft_links'])
         for var_name in self.data_root.groups['soft_links'].variables.keys(
         ):
             if hdf5 != None:
                 netcdf_utils.replicate_and_copy_variable(
                     output_grp,
                     self.data_root.groups['soft_links'],
                     var_name,
                     hdf5=hdf5['soft_links'],
                     check_empty=check_empty)
             else:
                 netcdf_utils.replicate_and_copy_variable(
                     output_grp,
                     self.data_root.groups['soft_links'],
                     var_name,
                     check_empty=check_empty)
     return
예제 #3
0
def record_to_file(output_root,output,output_hdf5):
    netcdf_utils.replicate_netcdf_file(output_root,output)
    #netcdf_utils.replicate_full_netcdf_recursive(output_root,output,check_empty=True)
    netcdf_utils.replicate_full_netcdf_recursive(output_root,output,check_empty=False,hdf5=output_hdf5)
    #netcdf_utils.replicate_full_netcdf_recursive(output_root,output,check_empty=True,hdf5=output_hdf5)
    return