예제 #1
0
    def __init__(self, line):
        self.ncode = None
        self.scode = None
        self.start = datetime(1980, 1, 1)
        self.end = None
        #print("  Station Attribute: %s" % line, file=sys.stderr)
        # Sa: Key=Value Net,Station,Location,Channel to=<Date> from=<Date>
        try:
            items = shlex.split(line)
            items.reverse()
            ns = items.pop()
            (self.ncode, self.scode) = ns.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:
                    raise Exception("invalid station reference")

            if self.start and self.end and self.start > self.end:
                raise Exception("station reference has invalid dates.")

        except Exception as e:
            raise Exception("Invalid Station Attribute line, " + str(e))
예제 #2
0
	def __init__(self, line):
		self.ncode = None
		self.scode = None
		self.start = datetime(1980,1,1)
		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()
			ns = items.pop()
			(self.ncode, self.scode) = ns.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:
					raise Exception("invalid station reference")

			if self.start and self.end and self.start > self.end:
				raise Exception("station reference has invalid dates.")
			
		except Exception,e:
			raise Exception("Invalid Station Attribute line, " + str(e))
예제 #3
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))
예제 #4
0
파일: basesc3.py 프로젝트: Fran89/seiscomp3
	def getDate(value):
		if isinstance(value, datetime.datetime):
			return Core.Time(*(value.timetuple()[:6]))
		elif isinstance(value, str):
			value = parsers.parseDate(value)
			return Core.Time(*(value.timetuple()[:6]))
		return value
예제 #5
0
 def getDate(value):
     if isinstance(value, datetime.datetime):
         return Core.Time(*(value.timetuple()[:6]))
     elif isinstance(value, str):
         value = parsers.parseDate(value)
         return Core.Time(*(value.timetuple()[:6]))
     return value
예제 #6
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))
예제 #7
0
	def __init__(self, line):
		self.att = {}
		try:
			#print >>sys.stderr,"Network:", line
			items = shlex.split(line)
			items.reverse()
			self.code  = items.pop()
			self.start = parsers.parseDate(items.pop())
			# Optional End data
			try:
				self.end = parsers.parseDate(items.pop())
			except:
				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))
		except Exception,e:
			raise Exception("Invalid Station Group header line," + str(e))
예제 #8
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))
예제 #9
0
 def __init__(self, line):
     self.att = {}
     try:
         #print("Network: %s" % line, file=sys.stderr)
         items = shlex.split(line)
         items.reverse()
         self.code = items.pop()
         self.start = parsers.parseDate(items.pop())
         # Optional End data
         try:
             self.end = parsers.parseDate(items.pop())
         except:
             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))
     except Exception as e:
         raise Exception("Invalid Station Group header line," + str(e))
예제 #10
0
 def __init__(self, line):
     self.att = {}
     try:
         #print >>sys.stderr,"Network:", line
         items = shlex.split(line)
         items.reverse()
         self.code = 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))
     except Exception, e:
         raise Exception("Invalid Network header line," + str(e))
예제 #11
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))
예제 #12
0
	def __init__(self, line):
		self.att = {}
		items = line.split()
		items.reverse()
		try:
			self.id = items.pop()
			self.date = parsers.parseDate("1980/001")
			self.gain = []
			self.gain.append(float(items.pop())) 
			self.gain.append(float(items.pop())) 
			self.gain.append(float(items.pop()))
			
			self.channelCount = len(self.gain)

			(self.type, self.instruments) = items.pop().split("_")
			self.instruments = self.instruments.split(",")
			
			if self.type != "S" and self.type != "L":
				raise Exception("Unknown calibration type %s" % self.type)
			
		except Exception,e:
			print >>sys.stderr, "Error parsing Calibration line, %s" % e
			raise Exception("Error!")
예제 #13
0
    def __init__(self, line):
        self.att = {}
        items = line.split()
        items.reverse()
        try:
            self.id = items.pop()
            self.date = parsers.parseDate("1980/001")
            self.gain = []
            self.gain.append(float(items.pop()))
            self.gain.append(float(items.pop()))
            self.gain.append(float(items.pop()))

            self.channelCount = len(self.gain)

            (self.type, self.instruments) = items.pop().split("_")
            self.instruments = self.instruments.split(",")

            if self.type != "S" and self.type != "L":
                raise Exception("Unknown calibration type %s" % self.type)

        except Exception as e:
            print("Error parsing Calibration line, %s" % e, file=sys.stderr)
            raise Exception("Error!")