예제 #1
0
    def renderEHDF(self):
        magtrans = {"Mww": "Mw"}  # magnitude translation table to get to 2 character magnitude types
        preforigin = self.preferredOrigin
        yr, mo, da, hr, mi, se, th = self.getTimePieces(preforigin["time"])
        lat = preforigin["lat"]
        lon = preforigin["lon"]
        lat, NS, lon, EW = self.getLatLon(lat, lon)
        lat = int(lat * 1000)
        lon = int(lon * 1000)
        dep = int(preforigin["depth"] * 10)
        depthtype = preforigin["depthtype"]
        # Depth type fields are:
        # from location
        # from moment tensor inversion
        # from from modeling of broad-band P waveforms
        # constrained by depth phases
        # constrained by direct phases
        # constrained by depth and direct phases
        # operator assigned
        # other.
        if depthtype.find("operator") > -1:
            depflag = "G"
        else:
            deptherror = preforigin["deptherr"]
            if not math.isnan(deptherror):
                if deptherror > 8.5 and deptherror <= 16.0:
                    depflag = "*"
                elif deptherror > 16.0:
                    depflag = "?"
                else:
                    depflag = " "
            else:
                depflag = " "
        numdep = preforigin["numphases"]  # these are the number of phases for the hypocenter... ok
        if numdep > 99:
            numdep = 99
        nump = numdep  # ??
        std = float("nan")
        # assign hypocenter quality
        axesmean = math.sqrt(preforigin["semimajor"] * preforigin["semiminor"])
        if axesmean <= 8.5:
            hypq = "%"
        elif axesmean > 8.5 and axesmean <= 16.0:
            hypq = "*"
        else:
            hypq = "?"
        magmb = float("nan")
        magmbsta = float("nan")
        magms = float("nan")
        magmssta = float("nan")
        magmscomp = "Z"
        mag1 = float("nan")  # contrib mag 1
        mag2 = float("nan")  # contrib mag 2
        mag1t = ""  # contrib mag 1 type
        mag2t = ""  # contrib mag 2 type
        mag1s = ""  # contrib mag 1 source
        mag2s = ""  # contrib mag 2 source
        magtypes = [mag["magtype"].lower() for mag in self.magnitudes]
        copymags = copy.copy(self.magnitudes)
        mag1, mag1t, mag1s, idx = self.getEHDFMagnitude(copymags)
        if idx >= 0:
            copymags.pop(idx)
        mag2, mag2t, mag2s, idx = self.getEHDFMagnitude(copymags)
        if idx >= 0:
            copymags.pop(idx)
        if "mb" in magtypes:
            idx = magtypes.index("mb")
            magmb = int(self.magnitudes[idx]["magnitude"] * 10)
            magmbsta = self.magnitudes[idx]["nstations"]
        if "ms" in magtypes:
            idx = magtypes.index("ms")
            magms = int(self.magnitudes[idx]["magnitude"] * 10)
            magmssta = self.magnitudes[idx]["nstations"]

        # Make sure that all magnitude types are two characters
        if mag1t in magtrans.keys():
            mag1t = magtrans[mag1t]
        if mag2t in magtrans.keys():
            mag2t = magtrans[mag2t]

        # make sure that magnitude contributors are 5 characters or less
        if len(mag1s) > 5:
            mag1s = mag1s[0:5]
        if len(mag2s) > 5:
            mag2s = mag2s[0:5]

        fenum = self.FENumber
        maxmi = "T"  # ?? what is unknown value
        # putting blanks for all flags for now - get Paul to fill in
        msflag = ""
        mtflag = ""
        if len(self.tensors):
            mtflag = "M"

        iiflag = ""  # ??
        fpflag = ""  # ??
        ieflag = ""
        dpflag = ""
        tsflag = ""
        seflag = ""
        voflag = ""
        ntflag = ""
        if self.EventType in EHDF_EVENT_TYPES.keys():
            ntflag = EHDF_EVENT_TYPES[eqdict["type"]]
        gwflag = ""
        gpflag = ""
        author = "%-5s" % (preforigin["author"])
        if len(author) > 5:
            author = author[0:5]
        vlist = [
            "GS",
            "",
            yr,
            mo,
            da,
            hr,
            mi,
            se,
            th,
            lat,
            NS,
            lon,
            EW,
            dep,
            depflag,
            numdep,
            nump,
            std,
            hypq,
            magmb,
            magmbsta,
            magms,
            magmssta,
            magmscomp,
            mag1,
            mag1t,
            mag1s,
            mag2,
            mag2t,
            mag2s,
            fenum,
            maxmi,
            msflag,
            mtflag,
            iiflag,
            fpflag,
            ieflag,
            dpflag,
            tsflag,
            seflag,
            voflag,
            ntflag,
            gwflag,
            gpflag,
            "<",
            author,
            ">",
        ]
        try:
            line = fixed.getFixedFormatString(EHDRFMT, vlist)
            return line
        except Exception, msg:
            sys.stderr.write('Could not create line for %s - error "%s"\n' % (self.eventcode, msg.message))
            return None
예제 #2
0
    def renderISF(self):
        isf = "BEGIN IMS1.0\n"
        isf += "MSG_TYPE DATA\n"
        isf += "MSG_ID %s\n" % self.eventcode.upper()
        isf += "DATA_TYPE BULLETIN IMS2.0:SHORT\n"
        preforigin = self.preferredOrigin
        if preforigin["analysistype"] == "m":
            isf += "The following is a MANUALLY REVIEWED LOCATION from the USGS/NEIC National Seismic Network System\n"
        else:
            isf += "The following is an AUTOMATICALLY REVIEWED LOCATION from the USGS/NEIC National Seismic Network System\n"

        isf += "Event   %s %s\n\n" % (self.eventcode.upper(), self.location)

        # if there is a url field, render that as a comment.  This should help with QA/QC
        if self.url is not None:
            isf += " (%s)" % self.url
            isf += "\n\n"

        # render the origin block
        hdrvalues = (
            "Date",
            "Time",
            "Err",
            "RMS",
            "Latitude",
            "Longitude",
            "Smaj",
            "Smin",
            "Az",
            "Depth",
            "Err",
            "Ndef",
            "Nst",
            "Gap",
            "mdist",
            "Mdist",
            "Qual",
            "Author",
            "OrigID",
        )
        line = fixed.getFixedFormatString(ORIGINHDR, hdrvalues)
        isf += line + "\n"
        for o in self.origins:
            # TODO - calculate these surface values from confidence ellipsoid at depth
            semimajor = float("nan")
            semiminor = float("nan")
            majorazimuth = float("nan")
            second = o["time"].second + o["time"].microsecond / 1e6
            vlist = [
                o["time"].year,
                "/",
                o["time"].month,
                "/",
                o["time"].day,
                o["time"].hour,
                ":",
                o["time"].minute,
                ":",
                second,
                o["timefixed"],
                o["time_error"],
                o["timerms"],
                o["lat"],
                o["lon"],
                o["epifixed"],
                semimajor,
                semiminor,
                majorazimuth,
                o["depth"],
                o["depthfixed"],
                o["deptherr"],
                o["numphases"],
                o["numstations"],
                o["azgap"],
                o["mindist"],
                o["maxdist"],
                o["analysistype"],
                o["locmethod"],
                o["event_type"],
                o["author"],
                " ",
            ]
            line = fixed.getFixedFormatString(ORIGINFMT, vlist)
            isf += line + "\n"

        isf += "\n"

        # render the magnitude block
        line = fixed.getFixedFormatString(MAGHDR, ["Magnitude", "Err", "Nsta", "Author", "OrigID"])
        isf += line + "\n"
        for m in self.magnitudes:
            vlist = [m["magtype"], " ", m["magnitude"], m["magerr"], m["nstations"], m["author"], m["dataid"]]
            line = fixed.getFixedFormatString(MAGFMT, vlist)
            isf += line + "\n"

        # render the moment tensor comment block
        isf += "\n"
        for m in self.tensors:
            line = fixed.getFixedFormatString(MOMENTHDR1, MOMENTLBL1)
            isf += line + "\n"
            line = fixed.getFixedFormatString(MOMENTHDR2, MOMENTLBL2)
            isf += line + "\n"
            vlist = [
                "(",
                "#",
                m["exponent"],
                m["scalarmoment"],
                m["fclvd"],
                m["mrr"],
                m["mtt"],
                m["mpp"],
                m["mrt"],
                m["mtp"],
                m["mrp"],
                m["nbodystations"],
                m["nsurfacestations"],
                m["dataid"],
            ]
            line = fixed.getFixedFormatString(MOMENTFMT1, vlist)
            isf += line + "\n"
            vlist = [
                "(",
                "#",
                m["momenterror"],
                m["clvderror"],
                m["mrrerror"],
                m["mtterror"],
                m["mpperror"],
                m["mrterror"],
                m["mrperror"],
                m["mtperror"],
                m["nbodycomp"],
                m["nsurfacecomp"],
                m["duration"],
            ]
            line = fixed.getFixedFormatString(MOMENTFMT2, vlist)
            isf += line + "\n"

        isf += "\n"

        # render the phase block
        line = fixed.getFixedFormatString(PHASEHDR, PHASELBL)
        isf += line + "\n"
        for p in self.phases:
            stacode = p["station"]
            second = p["time"].second + p["time"].microsecond / 1e6
            vlist = [
                stacode,
                p["distance"],
                p["stationazimuth"],
                p["phasetype"],
                p["time"].hour,
                ":",
                p["time"].minute,
                ":",
                second,
                p["timeres"],
                p["azimuth"],
                p["azres"],
                p["slowness"],
                p["slowres"],
                p["timeflag"],
                p["azflag"],
                p["slowflag"],
                p["snr"],
                p["amplitude"],
                p["period"],
                p["picktype"],
                p["direction"],
                p["quality"],
                p["magtype"],
                p["minmax"],
                p["mag"],
                p["arrid"],
            ]
            line = fixed.getFixedFormatString(PHASEFMT, vlist)
            isf += line + "\n"

        isf += "\n"

        isf += "STOP\n"

        return isf
예제 #3
0
파일: fixed.py 프로젝트: ekmyers/libcomcat
    def renderEHDF(self):
        magtrans = {'Mww':'Mw'} #magnitude translation table to get to 2 character magnitude types
        preforigin = self.preferredOrigin
        yr,mo,da,hr,mi,se,th = self.getTimePieces(preforigin['time'])
        lat = preforigin['lat']
        lon = preforigin['lon']
        lat,NS,lon,EW = self.getLatLon(lat,lon)
        lat = int(lat * 1000)
        lon = int(lon * 1000)
        dep = int(preforigin['depth']*10)
        depthtype = preforigin['depthtype']
        #Depth type fields are:
        # from location
        # from moment tensor inversion
        # from from modeling of broad-band P waveforms
        # constrained by depth phases
        # constrained by direct phases
        # constrained by depth and direct phases
        # operator assigned
        # other.
        if depthtype.find('operator') > -1:
            depflag = 'G'
        else:
            deptherror = preforigin['deptherr']
            if not math.isnan(deptherror):
                if deptherror > 8.5 and deptherror <= 16.0:
                    depflag = '*'
                elif deptherror > 16.0:
                    depflag = '?'
                else:
                    depflag = ' '
            else:
                depflag = ' '
        numdep = preforigin['numphases'] #these are the number of phases for the hypocenter... ok
        if numdep > 99:
            numdep = 99
        nump = numdep #??
        std = float('nan')
        #assign hypocenter quality
        axesmean = math.sqrt(preforigin['semimajor'] * preforigin['semiminor'])
        if axesmean <= 8.5:
            hypq = '%'
        elif axesmean > 8.5 and axesmean <= 16.0:
            hypq = '*'
        else:
            hypq = '?'
        magmb = float('nan')
        magmbsta = float('nan')
        magms = float('nan')
        magmssta = float('nan')
        magmscomp = 'Z'
        mag1 = float('nan') #contrib mag 1
        mag2 = float('nan') #contrib mag 2
        mag1t = '' #contrib mag 1 type
        mag2t = '' #contrib mag 2 type
        mag1s = '' #contrib mag 1 source
        mag2s = '' #contrib mag 2 source
        magtypes = [mag['magtype'].lower() for mag in self.magnitudes]
        copymags = copy.copy(self.magnitudes)
        mag1,mag1t,mag1s,idx = self.getEHDFMagnitude(copymags)
        if idx >= 0:
            copymags.pop(idx)
        mag2,mag2t,mag2s,idx = self.getEHDFMagnitude(copymags)
        if idx >= 0:
            copymags.pop(idx)
        if 'mb' in magtypes:
            idx = magtypes.index('mb')
            magmb = int(self.magnitudes[idx]['magnitude']*10)
            magmbsta = self.magnitudes[idx]['nstations']
            if magmbsta > 99:
                magmbsta = 99
        if 'ms' in magtypes:
            idx = magtypes.index('ms')
            magms = int(self.magnitudes[idx]['magnitude']*10)
            magmssta = self.magnitudes[idx]['nstations']
            if magmssta > 99:
                magmssta = 99

        #Make sure that all magnitude types are two characters
        if mag1t in magtrans.keys():
            mag1t = magtrans[mag1t]
        if mag2t in magtrans.keys():
            mag2t = magtrans[mag2t]

        #make sure that magnitude contributors are 5 characters or less
        if len(mag1s) > 5:
            mag1s = mag1s[0:5]
        if len(mag2s) > 5:
            mag2s = mag2s[0:5]

        fenum = self.FENumber
        maxmi = 'T' #?? what is unknown value
        #putting blanks for all flags for now - get Paul to fill in
        msflag = ''
        mtflag = ''
        if len(self.tensors):
            mtflag = 'M'
    
        iiflag = '' #??
        fpflag = '' #??
        ieflag = ''
        dpflag = ''
        tsflag = ''
        seflag = ''
        voflag = ''
        ntflag = ''
        if self.EventType in EHDF_EVENT_TYPES.keys():
            ntflag = EHDF_EVENT_TYPES[self.EventType]
        gwflag = ''
        gpflag = ''
        author = '%-5s' % (preforigin['author'])
        if len(author) > 5:
            author = author[0:5]
        vlist = ['GS','',yr,mo,da,hr,mi,se,th,lat,NS,lon,EW,dep,depflag,numdep,nump,std,hypq,
                 magmb,magmbsta,magms,magmssta,magmscomp,mag1,mag1t,mag1s,mag2,mag2t,mag2s,
                 fenum,maxmi,msflag,mtflag,iiflag,fpflag,ieflag,dpflag,tsflag,seflag,voflag,
                 ntflag,gwflag,gpflag,'<',author,'>']
        try:
            line = fixed.getFixedFormatString(EHDRFMT,vlist)
            return line
        except Exception,msg:
            sys.stderr.write('Could not create line for %s - error "%s"\n' % (self.eventcode,msg.message))
            return None
예제 #4
0
파일: fixed.py 프로젝트: ekmyers/libcomcat
    def renderISF(self):
        isf = 'BEGIN IMS1.0\n'
        isf += 'MSG_TYPE DATA\n'
        isf += 'MSG_ID %s\n' % self.eventcode.upper()
        isf += 'DATA_TYPE BULLETIN IMS2.0:SHORT\n'
        preforigin = self.preferredOrigin
        if preforigin['analysistype'] == 'm':
            isf += 'The following is a MANUALLY REVIEWED LOCATION from the USGS/NEIC National Seismic Network System\n'
        else:
            isf += 'The following is an AUTOMATICALLY REVIEWED LOCATION from the USGS/NEIC National Seismic Network System\n'
        
        isf += 'Event   %s %s\n\n' % (self.eventcode.upper(),self.location)

        #if there is a url field, render that as a comment.  This should help with QA/QC
        if self.url is not None:
            isf += ' (%s)' % self.url
            isf += '\n\n'

        #render the origin block
        hdrvalues = ('Date','Time','Err','RMS','Latitude','Longitude',
                   'Smaj','Smin','Az','Depth','Err','Ndef','Nst',
                   'Gap','mdist','Mdist','Qual','Author','OrigID')
        line = fixed.getFixedFormatString(ORIGINHDR,hdrvalues)
        isf += line+'\n'
        for o in self.origins:
            if not np.isnan(o['semimajor']):
                isFixed = True
                if o['depthtype'].lower().find('from location') > -1 or o['depthtype'].strip() == '':
                    isFixed = False
                semimajor,semiminor,majorazimuth = ellipse.tait2surface(o['semimajor'],
                                                                        o['semiminor'],
                                                                        o['intermediateaxis'],
                                                                        o['majorazimuth'],
                                                                        o['majorplunge'],
                                                                        o['majorrotation'],
                                                                        o['numphases'],
                                                                        o['originrms'],
                                                                        False)
            else:
                semimajor = semiminor = majorazimuth = np.nan
                
            second = o['time'].second + o['time'].microsecond/1e6
            vlist = [o['time'].year,'/',o['time'].month,'/',o['time'].day,
            o['time'].hour,':',o['time'].minute,':',second,o['timefixed'],
            o['time_error'],o['originrms'],o['lat'],o['lon'],o['epifixed'],semimajor,
            semiminor,majorazimuth,o['depth'],o['depthfixed'],o['deptherr'],
            o['numphases'],o['numstations'],o['azgap'],o['mindist'],o['maxdist'],
            o['analysistype'],o['locmethod'],o['event_type'],o['author'],' ']
            line = fixed.getFixedFormatString(ORIGINFMT,vlist)
            isf += line+'\n'

        isf += '\n'

        #render the magnitude block
        line = fixed.getFixedFormatString(MAGHDR,['Magnitude','Err','Nsta','Author','OrigID'])
        isf += line + '\n'
        for m in self.magnitudes:
            vlist = [m['magtype'],' ',m['magnitude'],m['magerr'],m['nstations'],m['author'],m['dataid']]
            line = fixed.getFixedFormatString(MAGFMT,vlist)
            isf += line+'\n'

        #render the moment tensor comment block
        isf += '\n'
        for m in self.tensors:
            line = fixed.getFixedFormatString(MOMENTHDR1,MOMENTLBL1)
            isf += line+'\n'
            line = fixed.getFixedFormatString(MOMENTHDR2,MOMENTLBL2)
            isf += line+'\n'
            vlist = ['(','#',m['exponent'],m['scalarmoment'],m['fclvd'],
                     m['mrr'],m['mtt'],m['mpp'],m['mrt'],m['mtp'],m['mrp'],
                     m['nbodystations'],m['nsurfacestations'],m['dataid']]
            line = fixed.getFixedFormatString(MOMENTFMT1,vlist)
            isf += line + '\n'
            vlist = ['(','#',m['momenterror'],m['clvderror'],
                     m['mrrerror'],m['mtterror'],m['mpperror'],
                     m['mrterror'],m['mrperror'],m['mtperror'],
                     m['nbodycomp'],m['nsurfacecomp'],m['duration']]
            line = fixed.getFixedFormatString(MOMENTFMT2,vlist)
            isf += line + '\n'

        isf += '\n'
            
        #render the phase block
        line = fixed.getFixedFormatString(PHASEHDR,PHASELBL)
        isf += line + '\n'
        for p in self.phases:
            stacode = p['station']
            second = p['time'].second + p['time'].microsecond/1e6
            vlist = [stacode,p['distance'],p['stationazimuth'],p['phasetype'],
                     p['time'].hour,':',p['time'].minute,':',second,p['timeres'],
                     p['azimuth'],p['azres'],p['slowness'],p['slowres'],p['timeflag'],
                     p['azflag'],p['slowflag'],p['snr'],p['amplitude'],p['period'],
                     p['picktype'],p['direction'],p['quality'],p['magtype'],
                     p['minmax'],p['mag'],p['arrid']]
            line = fixed.getFixedFormatString(PHASEFMT,vlist)
            isf += line+'\n'

        isf += '\n'
        
        isf += 'STOP\n'
        
        return isf
예제 #5
0
    def renderEHDF(self):
        magtrans = {
            'Mww': 'Mw'
        }  #magnitude translation table to get to 2 character magnitude types
        preforigin = self.preferredOrigin
        yr, mo, da, hr, mi, se, th = self.getTimePieces(preforigin['time'])
        lat = preforigin['lat']
        lon = preforigin['lon']
        lat, NS, lon, EW = self.getLatLon(lat, lon)
        lat = int(lat * 1000)
        lon = int(lon * 1000)
        dep = int(preforigin['depth'] * 10)
        depthtype = preforigin['depthtype']
        #Depth type fields are:
        # from location
        # from moment tensor inversion
        # from from modeling of broad-band P waveforms
        # constrained by depth phases
        # constrained by direct phases
        # constrained by depth and direct phases
        # operator assigned
        # other.
        if depthtype.find('operator') > -1:
            depflag = 'G'
        else:
            deptherror = preforigin['deptherr']
            if not math.isnan(deptherror):
                if deptherror > 8.5 and deptherror <= 16.0:
                    depflag = '*'
                elif deptherror > 16.0:
                    depflag = '?'
                else:
                    depflag = ' '
            else:
                depflag = ' '
        numdep = preforigin[
            'numphases']  #these are the number of phases for the hypocenter... ok
        if numdep > 99:
            numdep = 99
        nump = numdep  #??
        std = float('nan')
        #assign hypocenter quality
        axesmean = math.sqrt(preforigin['semimajor'] * preforigin['semiminor'])
        if axesmean <= 8.5:
            hypq = '%'
        elif axesmean > 8.5 and axesmean <= 16.0:
            hypq = '*'
        else:
            hypq = '?'
        magmb = float('nan')
        magmbsta = float('nan')
        magms = float('nan')
        magmssta = float('nan')
        magmscomp = 'Z'
        mag1 = float('nan')  #contrib mag 1
        mag2 = float('nan')  #contrib mag 2
        mag1t = ''  #contrib mag 1 type
        mag2t = ''  #contrib mag 2 type
        mag1s = ''  #contrib mag 1 source
        mag2s = ''  #contrib mag 2 source
        magtypes = [mag['magtype'].lower() for mag in self.magnitudes]
        copymags = copy.copy(self.magnitudes)
        mag1, mag1t, mag1s, idx = self.getEHDFMagnitude(copymags)
        if idx >= 0:
            copymags.pop(idx)
        mag2, mag2t, mag2s, idx = self.getEHDFMagnitude(copymags)
        if idx >= 0:
            copymags.pop(idx)
        if 'mb' in magtypes:
            idx = magtypes.index('mb')
            magmb = int(self.magnitudes[idx]['magnitude'] * 10)
            magmbsta = self.magnitudes[idx]['nstations']
        if 'ms' in magtypes:
            idx = magtypes.index('ms')
            magms = int(self.magnitudes[idx]['magnitude'] * 10)
            magmssta = self.magnitudes[idx]['nstations']

        #Make sure that all magnitude types are two characters
        if mag1t in magtrans.keys():
            mag1t = magtrans[mag1t]
        if mag2t in magtrans.keys():
            mag2t = magtrans[mag2t]

        #make sure that magnitude contributors are 5 characters or less
        if len(mag1s) > 5:
            mag1s = mag1s[0:5]
        if len(mag2s) > 5:
            mag2s = mag2s[0:5]

        fenum = self.FENumber
        maxmi = 'T'  #?? what is unknown value
        #putting blanks for all flags for now - get Paul to fill in
        msflag = ''
        mtflag = ''
        if len(self.tensors):
            mtflag = 'M'

        iiflag = ''  #??
        fpflag = ''  #??
        ieflag = ''
        dpflag = ''
        tsflag = ''
        seflag = ''
        voflag = ''
        ntflag = ''
        if self.EventType in EHDF_EVENT_TYPES.keys():
            ntflag = EHDF_EVENT_TYPES[eqdict['type']]
        gwflag = ''
        gpflag = ''
        author = '%-5s' % (preforigin['author'])
        if len(author) > 5:
            author = author[0:5]
        vlist = [
            'GS', '', yr, mo, da, hr, mi, se, th, lat, NS, lon, EW, dep,
            depflag, numdep, nump, std, hypq, magmb, magmbsta, magms, magmssta,
            magmscomp, mag1, mag1t, mag1s, mag2, mag2t, mag2s, fenum, maxmi,
            msflag, mtflag, iiflag, fpflag, ieflag, dpflag, tsflag, seflag,
            voflag, ntflag, gwflag, gpflag, '<', author, '>'
        ]
        try:
            line = fixed.getFixedFormatString(EHDRFMT, vlist)
            return line
        except Exception, msg:
            sys.stderr.write('Could not create line for %s - error "%s"\n' %
                             (self.eventcode, msg.message))
            return None
예제 #6
0
    def renderISF(self):
        isf = 'BEGIN IMS1.0\n'
        isf += 'MSG_TYPE DATA\n'
        isf += 'MSG_ID %s\n' % self.eventcode.upper()
        isf += 'DATA_TYPE BULLETIN IMS2.0:SHORT\n'
        preforigin = self.preferredOrigin
        if preforigin['analysistype'] == 'm':
            isf += 'The following is a MANUALLY REVIEWED LOCATION from the USGS/NEIC National Seismic Network System\n'
        else:
            isf += 'The following is an AUTOMATICALLY REVIEWED LOCATION from the USGS/NEIC National Seismic Network System\n'

        isf += 'Event   %s %s\n\n' % (self.eventcode.upper(), self.location)

        #if there is a url field, render that as a comment.  This should help with QA/QC
        if self.url is not None:
            isf += ' (%s)' % self.url
            isf += '\n\n'

        #render the origin block
        hdrvalues = ('Date', 'Time', 'Err', 'RMS', 'Latitude', 'Longitude',
                     'Smaj', 'Smin', 'Az', 'Depth', 'Err', 'Ndef', 'Nst',
                     'Gap', 'mdist', 'Mdist', 'Qual', 'Author', 'OrigID')
        line = fixed.getFixedFormatString(ORIGINHDR, hdrvalues)
        isf += line + '\n'
        for o in self.origins:
            #TODO - calculate these surface values from confidence ellipsoid at depth
            semimajor = float('nan')
            semiminor = float('nan')
            majorazimuth = float('nan')
            second = o['time'].second + o['time'].microsecond / 1e6
            vlist = [
                o['time'].year, '/', o['time'].month, '/', o['time'].day,
                o['time'].hour, ':', o['time'].minute, ':', second,
                o['timefixed'], o['time_error'], o['timerms'], o['lat'],
                o['lon'], o['epifixed'], semimajor, semiminor, majorazimuth,
                o['depth'], o['depthfixed'], o['deptherr'], o['numphases'],
                o['numstations'], o['azgap'], o['mindist'], o['maxdist'],
                o['analysistype'], o['locmethod'], o['event_type'],
                o['author'], ' '
            ]
            line = fixed.getFixedFormatString(ORIGINFMT, vlist)
            isf += line + '\n'

        isf += '\n'

        #render the magnitude block
        line = fixed.getFixedFormatString(
            MAGHDR, ['Magnitude', 'Err', 'Nsta', 'Author', 'OrigID'])
        isf += line + '\n'
        for m in self.magnitudes:
            vlist = [
                m['magtype'], ' ', m['magnitude'], m['magerr'], m['nstations'],
                m['author'], m['dataid']
            ]
            line = fixed.getFixedFormatString(MAGFMT, vlist)
            isf += line + '\n'

        #render the moment tensor comment block
        isf += '\n'
        for m in self.tensors:
            line = fixed.getFixedFormatString(MOMENTHDR1, MOMENTLBL1)
            isf += line + '\n'
            line = fixed.getFixedFormatString(MOMENTHDR2, MOMENTLBL2)
            isf += line + '\n'
            vlist = [
                '(', '#', m['exponent'], m['scalarmoment'], m['fclvd'],
                m['mrr'], m['mtt'], m['mpp'], m['mrt'], m['mtp'], m['mrp'],
                m['nbodystations'], m['nsurfacestations'], m['dataid']
            ]
            line = fixed.getFixedFormatString(MOMENTFMT1, vlist)
            isf += line + '\n'
            vlist = [
                '(', '#', m['momenterror'], m['clvderror'], m['mrrerror'],
                m['mtterror'], m['mpperror'], m['mrterror'], m['mrperror'],
                m['mtperror'], m['nbodycomp'], m['nsurfacecomp'], m['duration']
            ]
            line = fixed.getFixedFormatString(MOMENTFMT2, vlist)
            isf += line + '\n'

        isf += '\n'

        #render the phase block
        line = fixed.getFixedFormatString(PHASEHDR, PHASELBL)
        isf += line + '\n'
        for p in self.phases:
            stacode = p['station']
            second = p['time'].second + p['time'].microsecond / 1e6
            vlist = [
                stacode, p['distance'], p['stationazimuth'], p['phasetype'],
                p['time'].hour, ':', p['time'].minute, ':', second,
                p['timeres'], p['azimuth'], p['azres'], p['slowness'],
                p['slowres'], p['timeflag'], p['azflag'], p['slowflag'],
                p['snr'], p['amplitude'], p['period'], p['picktype'],
                p['direction'], p['quality'], p['magtype'], p['minmax'],
                p['mag'], p['arrid']
            ]
            line = fixed.getFixedFormatString(PHASEFMT, vlist)
            isf += line + '\n'

        isf += '\n'

        isf += 'STOP\n'

        return isf