Ejemplo n.º 1
0
    def __init__(self, line):
        # This are other default values
        self.compression = "2"
        self.gainCode = "H"
        self.location = ""
        self.channels = {}
        self.orientations = {}
        self.attStation = {}
        self.attLocation = {}
        try:
            items = shlex.split(line)
            items.reverse()
            self.code = parsers.parseStationCode(items.pop())
            _pc = items.pop()
            if _pc.find("/") != -1:
                (self._place, self._country) = _pc.split("/", 1)
                self._place = self._place.strip()
                self._country = self._country.strip()
            else:
                self._place = _pc.strip()
                self._country = ""
            (self._datalogger, self._dataloggerSerialNumber,
             self.dataloggerGain) = self._parseInstrument(items.pop())
            (self._sensor, self._sensorSerialNumber,
             self.sensorGain) = self._parseInstrument(items.pop())
            self._sampling = items.pop()
            self._orientation = items.pop()
            self._latitude = parsers.parseLatitude(items.pop())
            self._longitude = parsers.parseLongitude(items.pop())
            self._elevation = parsers.parseElevation(items.pop())
            self._depth = parsers.parseDepth(items.pop())
            self.start = parsers.parseDate(items.pop())
            # Optional End data
            try:
                self.end = parsers.parseDate(items.pop())
            except IndexError:
                self.end = None
            # Start < End
            if self.end and self.start > self.end:
                raise Exception("End Date before Start Date at line, %s %s" %
                                (self.start, self.end))
            # Parse the Sampling string
            self._parseOrientation(self._orientation)
            # Parse the Sampling string
            self._parseSampling(self._sampling)

            if verboseFlag:
                print("Station Line:",
                      self.code,
                      self.start,
                      "->",
                      self.end,
                      self._sampling,
                      self._orientation,
                      file=sys.stderr)
        except Exception as e:
            raise Exception("Invalid Station line, " + str(e))
Ejemplo n.º 2
0
	def __init__(self, line):
		# This are other default values
		self.compression = "2"
		self.gainCode = "H"
		self.location = ""
		self.channels = {}
		self.orientations = {}
		self.attStation = {}
		self.attLocation = {}
		try:
			items = shlex.split(line)
			items.reverse()
			self.code = parsers.parseStationCode(items.pop())
			_pc = items.pop()
			if _pc.find("/") != -1:
				(self._place, self._country) = _pc.split("/",1)
				self._place = self._place.strip()
				self._country = self._country.strip()				
			else:
				self._place = _pc.strip()
				self._country = ""
			(self._datalogger, self._dataloggerSerialNumber, self.dataloggerGain) = self._parseInstrument(items.pop())
			(self._sensor, self._sensorSerialNumber, self.sensorGain) = self._parseInstrument(items.pop())
			self._sampling = items.pop()
			self._orientation = items.pop()
			self._latitude = parsers.parseLatitude(items.pop())
			self._longitude = parsers.parseLongitude(items.pop())
			self._elevation = parsers.parseElevation(items.pop())
			self._depth = parsers.parseDepth(items.pop())
			self.start = parsers.parseDate(items.pop())
			# Optional End data
			try:
				self.end = parsers.parseDate(items.pop())
			except IndexError:
				self.end = None
			# Start < End
			if self.end and self.start > self.end:
				raise Exception("End Date before Start Date at line, %s %s" % (self.start, self.end))
			# Parse the Sampling string
			self._parseOrientation(self._orientation)
			# Parse the Sampling string
			self._parseSampling(self._sampling)

			if verboseFlag: print >> sys.stderr,"Station Line:", self.code, self.start,"->",self.end, self._sampling, self._orientation
		except Exception, e:
			raise Exception("Invalid Station line, " + str(e))
Ejemplo n.º 3
0
    def __init__(self, line):
        self.items = []
        self.start = None
        self.end = None
        #print("  Station Attribute:", line, file=sys.stderr)
        # Sa: Key=Value Net,Station,Location,Channel to=<Date> from=<Date>
        try:
            items = shlex.split(line)
            items.reverse()
            keypair = items.pop()
            (key, value) = keypair.split("=", 1)
            for item in items:
                if item[0:3] == "to=":
                    self.end = parsers.parseDate(item[3:])
                elif item[0:5] == "from=":
                    self.start = parsers.parseDate(item[5:])
                else:
                    items = item.split(",")
                    items.reverse()
                    try:
                        station = parsers.parseStationCode(items.pop())
                    except IndexError:
                        station = None
                    try:
                        location = parsers.parseLocationCode(items.pop())
                    except IndexError:
                        location = None
                    try:
                        channel = parsers.parseChannelCode(items.pop())
                    except IndexError:
                        channel = None

                    (self.Key,
                     self.Value) = self._validate(key, value, station,
                                                  location, channel)
                    ## print("Adding %s: %s %s %s" % (self.Key, station,location,channel), file=sys.stderr)
                    self.items.append((station, location, channel))
            if self.start and self.end and self.start > self.end:
                raise Exception("attribute has invalid dates.")
            if len(self.items) == 0:
                raise Exception("no channel pattern specified.")

        except Exception as e:
            raise Exception("Invalid Station Attribute line, " + str(e))
Ejemplo n.º 4
0
	def __init__(self, line):
		self.items = []
		self.start = None
		self.end = None
		#print >>sys.stderr,"  Station Attribute:", line
		# Sa: Key=Value Net,Station,Location,Channel to=<Date> from=<Date>
		try:
			items = shlex.split(line)
			items.reverse()
			keypair=items.pop()
			(key,value) = keypair.split("=",1)
			for item in items:
				if item[0:3] == "to=":
					self.end = parsers.parseDate(item[3:])
				elif item[0:5] == "from=":
					self.start = parsers.parseDate(item[5:])
				else:
					items = item.split(",")
					items.reverse()
					try:
						station = parsers.parseStationCode(items.pop())
					except IndexError:
						station = None
					try:
						location = parsers.parseLocationCode(items.pop())
					except IndexError:
						location = None
					try:
						channel = parsers.parseChannelCode(items.pop())
					except IndexError:
						channel = None

					(self.Key, self.Value) = self._validate(key, value, station, location, channel)
					## print >>sys.stderr,"Adding %s: %s %s %s" % (self.Key, station,location,channel)
					self.items.append((station,location,channel))
			if self.start and self.end and self.start > self.end:
				raise Exception("attribute has invalid dates.")
			if len(self.items) == 0:
				raise Exception("no channel pattern specified.")
			
		except Exception,e:
			raise Exception("Invalid Station Attribute line, " + str(e))