예제 #1
0
        
        
        m = max(data['pressure'])
        if m > max_abs_pressure:
            max_abs_pressure = m
        m_ind = [i for i, j in enumerate(data['pressure']) if j ==m] # this line finds the index of the max depth
        
        
        #this loop here will take the readings only when the fish is going down
        for j in names:
            vars()[j] = []
            for i in np.arange(1,float(m_ind[0])):
                if data['pressure'][i]-data['pressure'][i-1] >0:
                    vars()[j].append(data[str(j)][i])
                    
        depth = sw.depth(pressure, xyzt['lat_DD.dd'])        
        c3515 = 42.9140
        condr = [x/c3515 for x in cond]
        salinity = sw.salt(condr, temp, pressure)
        density = sw.dens(salinity, temp,pressure)  
        griddeddata=[]
    
        for k in names2:
            griddeddata = np.interp(grid_depth,depth,vars()[k],right=np.NaN)
            griddeddata = griddeddata[0:]
            vars()['grid_'+k][:,file[0]] = vars()['griddeddata']

        f.close()
    except:
        failedloadfiles.append(str(file))
        print ("Could not process " + file[1])
예제 #2
0
    def write_pctd(self, inFile):
        '''
        Write lists out as NetCDF using the base name of the file for the .nc file that this creates.
        '''

        outFile = '.'.join(inFile.split('.')[:-1]) + '.nc'

        # Create the NetCDF file
        self.ncFile = netcdf_file(outFile, 'w')

        # If specified on command line override the default generic title with what is specified
        self.ncFile.title = 'Profile CTD cast data'
        if self.args.title:
            self.ncFile.title = self.args.title

        # Combine any summary text specified on commamd line with the generic summary stating the original source file
        self.ncFile.summary = 'Observational oceanographic data translated with no modification from original data file %s' % inFile
        if self.args.summary:
            self.ncFile.summary = self.args.summary
            if not self.args.summary.endswith('.'):
                self.ncFile.summary += '.'
            self.ncFile.summary += ' Translated with no modification from original data file %s' % inFile

        # If specified on command line override the default generic license with what is specified
        if self.args.license:
            self.ncFile.license = self.args.license

        # Trajectory dataset, time is the only netCDF dimension
        self.ncFile.createDimension('time', len(self.esec_list))
        self.time = self.ncFile.createVariable('time', 'float64', ('time',))
        self.time.standard_name = 'time'
        self.time.units = 'seconds since 1970-01-01'
        self.time[:] = self.esec_list

        # Record Variables - coordinates for trajectory - save in the instance and use for metadata generation
        self.latitude = self.ncFile.createVariable('latitude', 'float64', ('time',))
        self.latitude.long_name = 'LATITUDE'
        self.latitude.standard_name = 'latitude'
        self.latitude.units = 'degree_north'
        self.latitude[:] = self.lat_list

        self.longitude = self.ncFile.createVariable('longitude', 'float64', ('time',))
        self.longitude.long_name = 'LONGITUDE'
        self.longitude.standard_name = 'longitude'
        self.longitude.units = 'degree_east'
        self.longitude[:] = self.lon_list

        self.depth = self.ncFile.createVariable('depth', 'float64', ('time',))
        self.depth.long_name = 'DEPTH'
        self.depth.standard_name = 'depth'
        self.depth.units = 'm'
        self.depth[:] = csiro.depth(self.pr_list, self.lat_list)      # Convert pressure to depth

        # Record Variables - Profile CTD Data
        temp = self.ncFile.createVariable('TEMP', 'float64', ('time',))
        temp.long_name = 'Temperature, [ITS-90, deg C]'
        temp.standard_name = 'sea_water_temperature'
        temp.coordinates = 'time depth latitude longitude'
        temp.units = 'Celsius'
        temp[:] = self.t_list

        sal = self.ncFile.createVariable('PSAL', 'float64', ('time',))
        sal.long_name = 'Salinity, Practical [PSU]'
        sal.standard_name = 'sea_water_salinity'
        sal.coordinates = 'time depth latitude longitude'
        sal[:] = self.sal_list

        xmiss = self.ncFile.createVariable('xmiss', 'float64', ('time',))
        xmiss.long_name = 'Beam Transmission, Chelsea/Seatech'
        xmiss.coordinates = 'time depth latitude longitude'
        xmiss.missing_value = self.missing_value
        xmiss._FillValue = self._FillValue
        xmiss.units = '%'
        xmiss[:] = self.xmiss_list

        if self.ecofl_list:
            ecofl = self.ncFile.createVariable('ecofl', 'float64', ('time',))
            ecofl.long_name = 'Fluorescence, WET Labs ECO-AFL/FL'
            ecofl.coordinates = 'time depth latitude longitude'
            ecofl.units = 'mg/m^3'
            ecofl[:] = self.ecofl_list

        if self.wetstar_list:
            wetstar = self.ncFile.createVariable('wetstar', 'float64', ('time',))
            wetstar.long_name = 'Fluorescence, WET Labs WETstar'
            wetstar.coordinates = 'time depth latitude longitude'
            wetstar.units = 'mg/m^3'
            wetstar[:] = self.wetstar_list

        if self.oxygen_list:
            oxygen = self.ncFile.createVariable('oxygen', 'float64', ('time',))
            oxygen.long_name = 'Oxygen, SBE 43'
            oxygen.coordinates = 'time depth latitude longitude'
            oxygen.units = 'ml/l'
            oxygen[:] = self.oxygen_list

        if self.args.analog:
            if self.analog_list:
                analog = self.ncFile.createVariable(self.an_var, 'float64', ('time',))
                analog.coordinates = 'time depth latitude longitude'
                analog.units = self.an_units
                analog[:] = self.analog_list

        self.add_global_metadata()

        self.ncFile.close()
        print 'Wrote ' + outFile
예제 #3
0
    def write_pctd(self, inFile):
        '''
        Write lists out as NetCDF using the base name of the file for the .nc file that this creates.
        '''

        outFile = '.'.join(inFile.split('.')[:-1]) + '.nc'

        # Create the NetCDF file
        self.ncFile = netcdf_file(outFile, 'w')

        # If specified on command line override the default generic title with what is specified
        self.ncFile.title = 'Profile CTD cast data'
        if self.args.title:
            self.ncFile.title = self.args.title

        # Combine any summary text specified on commamd line with the generic summary stating the original source file
        self.ncFile.summary = 'Observational oceanographic data translated with no modification from original data file %s' % inFile
        if self.args.summary:
            self.ncFile.summary = self.args.summary
            if not self.args.summary.endswith('.'):
                self.ncFile.summary += '.'
            self.ncFile.summary += ' Translated with no modification from original data file %s' % inFile

        # If specified on command line override the default generic license with what is specified
        if self.args.license:
            self.ncFile.license = self.args.license

        # Trajectory dataset, time is the only netCDF dimension
        self.ncFile.createDimension('time', len(self.esec_list))
        self.time = self.ncFile.createVariable('time', 'float64', ('time', ))
        self.time.standard_name = 'time'
        self.time.units = 'seconds since 1970-01-01'
        self.time[:] = self.esec_list

        # Record Variables - coordinates for trajectory - save in the instance and use for metadata generation
        self.latitude = self.ncFile.createVariable('latitude', 'float64',
                                                   ('time', ))
        self.latitude.long_name = 'LATITUDE'
        self.latitude.standard_name = 'latitude'
        self.latitude.units = 'degree_north'
        self.latitude[:] = self.lat_list

        self.longitude = self.ncFile.createVariable('longitude', 'float64',
                                                    ('time', ))
        self.longitude.long_name = 'LONGITUDE'
        self.longitude.standard_name = 'longitude'
        self.longitude.units = 'degree_east'
        self.longitude[:] = self.lon_list

        self.depth = self.ncFile.createVariable('depth', 'float64', ('time', ))
        self.depth.long_name = 'DEPTH'
        self.depth.standard_name = 'depth'
        self.depth.units = 'm'
        self.depth[:] = csiro.depth(self.pr_list,
                                    self.lat_list)  # Convert pressure to depth

        # Record Variables - Profile CTD Data
        temp = self.ncFile.createVariable('TEMP', 'float64', ('time', ))
        temp.long_name = 'Temperature, [ITS-90, deg C]'
        temp.standard_name = 'sea_water_temperature'
        temp.coordinates = 'time depth latitude longitude'
        temp.units = 'Celsius'
        temp[:] = self.t_list

        sal = self.ncFile.createVariable('PSAL', 'float64', ('time', ))
        sal.long_name = 'Salinity, Practical [PSU]'
        sal.standard_name = 'sea_water_salinity'
        sal.coordinates = 'time depth latitude longitude'
        sal[:] = self.sal_list

        xmiss = self.ncFile.createVariable('xmiss', 'float64', ('time', ))
        xmiss.long_name = 'Beam Transmission, Chelsea/Seatech'
        xmiss.coordinates = 'time depth latitude longitude'
        xmiss.missing_value = self.missing_value
        xmiss._FillValue = self._FillValue
        xmiss.units = '%'
        xmiss[:] = self.xmiss_list

        if self.ecofl_list:
            ecofl = self.ncFile.createVariable('ecofl', 'float64', ('time', ))
            ecofl.long_name = 'Fluorescence, WET Labs ECO-AFL/FL'
            ecofl.coordinates = 'time depth latitude longitude'
            ecofl.units = 'mg/m^3'
            ecofl[:] = self.ecofl_list

        if self.wetstar_list:
            wetstar = self.ncFile.createVariable('wetstar', 'float64',
                                                 ('time', ))
            wetstar.long_name = 'Fluorescence, WET Labs WETstar'
            wetstar.coordinates = 'time depth latitude longitude'
            wetstar.units = 'mg/m^3'
            wetstar[:] = self.wetstar_list

        if self.oxygen_list:
            oxygen = self.ncFile.createVariable('oxygen', 'float64',
                                                ('time', ))
            oxygen.long_name = 'Oxygen, SBE 43'
            oxygen.coordinates = 'time depth latitude longitude'
            oxygen.units = 'ml/l'
            oxygen[:] = self.oxygen_list

        if self.args.analog:
            if self.analog_list:
                analog = self.ncFile.createVariable(self.an_var, 'float64',
                                                    ('time', ))
                analog.coordinates = 'time depth latitude longitude'
                analog.units = self.an_units
                analog[:] = self.analog_list

        self.add_global_metadata()

        self.ncFile.close()
        print 'Wrote ' + outFile
예제 #4
0
파일: test.py 프로젝트: justkeating/stoqs
    def write_pctd(self, inFile):
        '''
        Write lists out as NetCDF using the base name of the file for the .nc file that this creates.
        '''

        outFile = '.'.join(inFile.split('.')[:-1]) + '.nc'

        # Create the NetCDF file
        self.ncFile = netcdf_file(outFile, 'w')
        self.outFile = outFile

        # Trajectory dataset, time is the only netCDF dimension
        self.ncFile.createDimension('time', len(self.esec_list))
        self.time = self.ncFile.createVariable('time', 'float64', ('time',))
        self.time.standard_name = 'time'
        self.time.units = 'seconds since 1970-01-01'
        self.time[:] = self.esec_list

        # Record Variables - coordinates for trajectory - save in the instance and use for metadata generation
        self.latitude = self.ncFile.createVariable('latitude', 'float64', ('time',))
        self.latitude.long_name = 'LATITUDE'
        self.latitude.standard_name = 'latitude'
        self.latitude.units = 'degree_north'
        self.latitude[:] = self.lat_list

        self.longitude = self.ncFile.createVariable('longitude', 'float64', ('time',))
        self.longitude.long_name = 'LONGITUDE'
        self.longitude.standard_name = 'longitude'
        self.longitude.units = 'degree_east'
        self.longitude[:] = self.lon_list

        self.depth = self.ncFile.createVariable('depth', 'float64', ('time',))
        self.depth.long_name = 'DEPTH'
        self.depth.standard_name = 'depth'
        self.depth.units = 'm'
        self.depth[:] = csiro.depth(self.pr_list, self.lat_list)      # Convert pressure to depth

        # Record Variables - Profile CTD Data
        temp = self.ncFile.createVariable('TEMP', 'float64', ('time',))
        temp.long_name = 'Temperature, [ITS-90, deg C]'
        temp.standard_name = 'sea_water_temperature'
        temp.coordinates = 'time depth latitude longitude'
        temp.units = 'Celsius'
        temp[:] = self.t_list

        sal = self.ncFile.createVariable('PSAL', 'float64', ('time',))
        sal.long_name = 'Salinity, Practical [PSU]'
        sal.standard_name = 'sea_water_salinity'
        sal.coordinates = 'time depth latitude longitude'
        sal[:] = self.sal_list

        xmiss = self.ncFile.createVariable('xmiss', 'float64', ('time',))
        xmiss.long_name = 'Beam Transmission, Chelsea/Seatech'
        xmiss.coordinates = 'time depth latitude longitude'
        xmiss.units = '%'
        xmiss[:] = self.xmiss_list

        if self.ecofl_list:
            ecofl = self.ncFile.createVariable('ecofl', 'float64', ('time',))
            ecofl.long_name = 'Fluorescence, WET Labs ECO-AFL/FL'
            ecofl.coordinates = 'time depth latitude longitude'
            ecofl.units = 'mg/m^3'
            ecofl[:] = self.ecofl_list

        if self.wetstar_list:
            wetstar = self.ncFile.createVariable('wetstar', 'float64', ('time',))
            wetstar.long_name = 'Fluorescence, WET Labs WETstar'
            wetstar.coordinates = 'time depth latitude longitude'
            wetstar.units = 'mg/m^3'
            wetstar[:] = self.wetstar_list

        if self.oxygen_list:
            oxygen = self.ncFile.createVariable('oxygen', 'float64', ('time',))
            oxygen.long_name = 'Oxygen, SBE 43'
            oxygen.coordinates = 'time depth latitude longitude'
            oxygen.units = 'ml/l'
            oxygen[:] = self.oxygen_list

        if self.oxyps_list:
            oxygen = self.ncFile.createVariable('oxygen_ps', 'float64', ('time',))
            oxygen.long_name = 'Oxygen, SBE 43'
            oxygen.coordinates = 'time depth latitude longitude'
            oxygen.units = '%'
            oxygen[:] = self.oxyps_list

        self.add_global_metadata()

        self.ncFile.close()