Esempio n. 1
0
 def to_XMLCatalog(self):
   """ This function creates an xml eqcatalog entry for an rea file and returns the xmlstr value"""
   if self.catalog_report():
     mag,type,agency=self.maximum_magnitude()
     cat=dict(entry='EQ',id=self.id)
     cat['latitude']="%.4f" % (self.ha['latitude'])
     cat['longitude']="%.4f" % (self.ha['longitude'])
     cat['depth']="%.2f" % (self.ha['depth'])
     cat['magnitude']="%.1f" % (mag)
     cat['magnitudetype']=type
     cat['laterror']="%.2f" % (self.error['latitude'])
     cat['lonerror']="%.2f" % (self.error['longitude'])
     cat['deptherror']="%.2f" % (self.error['depth'])
     cat['oterror']="%.2f" % (self.error['origintime'])
     cat['origintime']="%s" % (self.origin_time.isoformat(" "))
     if eqcatalog.isdst(self.origin_time):
       ltime= self.origin_time - timedelta(hours=5.0)
       cat['localtime']="%s CDT" % (ltime.isoformat(" "))
     else:
       ltime= self.origin_time - timedelta(hours=6.0)
       cat['localtime']="%s CST" % (ltime.isoformat(" "))
     cat['nstas']="%i" % (self.no_sta)
     cat['rms']="%.2f" % (self.ha['rms'])
     cat['MaxMMI']=eqcatalog.roman_intensity(self.maximum_intensity)
     cat['updated']=datetime.utcfromtimestamp(self.file_mtime).isoformat("T")
     return eqcatalog.dict2xml(cat,2)
   else:
     return ''
Esempio n. 2
0
  def to_GEORSS(self):
# This function generates georss records from rea objects.
#The tcompare value is a datetime value.  For records to be reported they need to have origin times after this value
    if self.catalog_report():
      mag,type,agency=self.maximum_magnitude()
      cat=dict(entry='entry',id=self.id)
      cat['pubdate']=datetime.utcfromtimestamp(self.file_mtime).isoformat("T")
      cat['title']="M %.1f, %s UTC" % (mag, self.origin_time.isoformat(" "))
      ttime=time.localtime(time.mktime(self.origin_time.timetuple()))
      if eqcatalog.isdst(self.origin_time):
        ltime= self.origin_time - timedelta(hours=5.0)
        cat['summary']="Origin Time %s UTC (%s CDT), Magnitude %.1f %s" % (self.origin_time.isoformat(" "),ltime.isoformat(" "),mag,type)
      else:
        ltime= self.origin_time - timedelta(hours=6.0)
        cat['summary']="Origin Time %s UTC (%s CST), Magnitude %.1f %s" % (self.origin_time.isoformat(" "),ltime.isoformat(" "),mag,type)

        
      cat['georss:point']="%f %f" % (self.ha['latitude'],self.ha['longitude'])
        
      return eqcatalog.dict2xml(cat,4)
    else:
      return ''