コード例 #1
0
ファイル: rea.py プロジェクト: AntonyButcher/seismic-code
 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 ''
コード例 #2
0
ファイル: rea.py プロジェクト: AntonyButcher/seismic-code
 def to_simpleList(self):
     if eqcatalog.isdst(self.origin_time):
       ltime= self.origin_time - timedelta(hours=5.0)
       tstr="%s CDT" % (ltime.isoformat(" "))
     else:
       ltime= self.origin_time - timedelta(hours=6.0)
       tstr="%s CDT" % (ltime.isoformat(" "))
     mstr="%.1f %s %s" % (self.maximum_magnitude())
     #print self.ha['latitude']
     #print self.error['latitude']
     return [tstr,self.ha['latitude'],self.error['latitude'],self.ha['longitude'],
       self.error['longitude'],self.ha['depth'],self.error['depth'],mstr]
コード例 #3
0
ファイル: rea.py プロジェクト: AntonyButcher/seismic-code
  def to_HTML(self,filename=None):
    """ object.to_HTML(filename)
    If filename is not defined then the output is directed to standard out.
    """
    from eqcatalog import calc_localtime,isdst
    if not filename:
      fh=sys.stdout
    else:
      fh=open(filename,'w')
    fh.write("<html>\n")
    fh.write("<div style=\"width:600px,padding:20px;\">\n")
    fh.write("<h2>Earthquake Details: Magnitude %.1f - %s</h2>\n" % (self.preferred_magnitude()[0],self.origin_time.isoformat(" ")))
    fh.write("<table style=\"border: 1px solid black;\">\n")
  
    if isdst(self.origin_time):
      ltimestr="%s (CDT)" % (calc_localtime(self.origin_time))
    else:
      ltimestr="%s (CST)" % (calc_localtime(self.origin_time))

    fh.write("<tr><td style=\"font-weight:bold;vertical-align:top;\">Origin Time</td><td>%s (UTC)<br />%s<br />Uncertainty: %.3f seconds</td>\n" % (self.origin_time.isoformat(" "),ltimestr,self.error['origintime']))
    fh.write("<tr><td style=\"font-weight:bold;vertical-align:top;\">Location</td><td>Latitude: %.4f&deg; &plusmn; %.2f (km)<br />Longitude: %.4f&deg; &plusmn; %.2f (km) <br />Depth: %.2f &plusmn; %.2f km</td>\n" % (self.latitude,self.error['latitude'],self.longitude,self.error['longitude'],self.depth,self.error['depth']))
    magstr=''
    for i in range(0,len(self.magnitude)): # Build magnitude string
      magstr+="%.1f %s %s<br />" % (self.magnitude[i],self.magnitude_type[i],self.magnitude_agency[i])
    fh.write("<tr><td style=\"font-weight:bold;vertical-align:top;\">Magnitude</td><td>%s</td>\n" % (magstr))
    fh.write("<tr><td style=\"font-weight:bold;vertical-align:top;\">Maximum Modified Mercalli Intensity</td><td>%s</td>\n" % (eqcatalog.roman_intensity(self.maximum_intensity)))
    if self.focmec.has_key('strike'):
        mechstr="Strike: %.1f&deg;<br />Dip: %.1f&deg;<br />Rake: %.1f&deg;<br />Agency: %s<br />Method: %s,<br />" % (self.focmec['strike'],self.focmec['dip'],self.focmec['rake'],self.focmec['agency'],self.focmec['source'])
        fh.write("<tr><td style=\"font-weight:bold;vertical-align:top;\">Focal Mechanism</td><td>%s</td>\n" % (mechstr))
    fh.write("<tr><td style=\"font-weight:bold;vertical-align:top;\">Number of Stations</td><td>%d</td>\n" % (self.no_sta))
    fh.write("<tr><td style=\"font-weight:bold;vertical-align:top;\">Location RMS</td><td>%.2f</td>\n" % (self.rms))
    fh.write("<tr><td style=\"font-weight:bold;vertical-align:top;\">Last Updated</td><td>%s UTC</td>\n" % (datetime.utcfromtimestamp(self.file_mtime).isoformat(" ")))

    fh.write("</table>")

    #Write out the end of file and close
    fh.write("</div>\n</html>\n")
    if filename:
      fh.close()
    return True
コード例 #4
0
ファイル: rea.py プロジェクト: AntonyButcher/seismic-code
  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 ''