Coverage for runmacs/spec/io/ames.py : 55%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*- ames ====
NASA AMES file format reader """ # Filename: ames.py
######################################################################### # # ames.py - This file is part of the Munich Aerosol Cloud Scanner package. # # Copyright (C) 2012-2018 Florian Ewald # # runMACS is free software; you can redistribute it and/ # or modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # Spectral Python is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this software; if not, write to # # Free Software Foundation, Inc. # 59 Temple Place, Suite 330 # Boston, MA 02111-1307 # USA # ######################################################################### # # Send comments to: # Tobias Koelling, tobias.koelling@physik.uni-muenchen.de #
def read_csv(filename, skiprows, *_, **_2): """ Read csv data using numpy """ return np.loadtxt(filename, skiprows=skiprows+1) else: """ Read csv data using pandas """
""" Reader for the NASA AMES file format """ skiprows=self._header.getNumHeaderLines()-1, delim_whitespace=True, engine='c', decimal='.') for x in self._data[..., 0]]) """ Finds the index of the variable unambigously defined by ``name``. The ``name`` may be a substring of the full name. """ for i, v in enumerate(self._header.getVariables()) if name in v[0]] raise ValueError('name "%s" is ambigous'%name) raise ValueError('name "%s" not found'%name) else: """ Returns the contents of the variable given by one of:
* The index of the variable * The name of the variable * An unambigous part of the name of the variable """ return self._data[..., i_or_name] else: return self._data[key] return getattr(self._header, name)
def source(self): """ The measurement source """ return self._header.getSource() def originator(self): """ The measureing person """ return self._header.getOriginator() def organisation(self): """ The measureing organisation """ return self._header.getOrg() def mission(self): """ The mission during which the data has been acquired """ return self._header.getMission() def normalComments(self): """ Comment for the whole dataset """ return self._header.getNormalComments() def specialComments(self): """ Comment special for this file """ return self._header.getSpecialComments()
""" Reader for AMES files of the CAS sonde """ Ambient number concentration > 3um (cm^-3) Ambient number concentration < 3um (cm^-3) Effective diameter (um) Mean Volume Diameter (um) Ice Water Content (g m^-3) Bin_0 Bin_1 Bin_2 Bin_3 Bin_4 Bin_5 Bin_6 Bin_7 Bin_8 Bin_9 Bin_10 Bin_11 Bin_12 Bin_13 Bin_14 Bin_15 Bin_16 Particle air speed (PAS) measured at the instrument (m/s) """.split('\n'))
self._skip = int(open(filename).next().split()[0]) self._data = np.loadtxt(filename, skiprows=self._skip) self._basedate = basedate self.time = np.array([self._basedate + datetime.timedelta(seconds=x) for x in self._data[..., 0]])
""" Finds the index of the variable unambigously defined by ``name``. The ``name`` may be a substring of the full name. """ possible_indices = [i+1 for i, v in enumerate(self.variables) if name in v] if len(possible_indices) > 1: raise ValueError('name "%s" is ambigous' % name) elif len(possible_indices) == 0: raise ValueError('name "%s" not found' % name) else: return possible_indices[0]
""" Returns the contents of the variable given by one of:
* The index of the variable * The name of the variable * An unambigous part of the name of the variable """ if isinstance(i_or_name, int): return self._data[..., i_or_name] else: return self._data[..., self.getIndex(i_or_name)]
return self._data[key]
|