"""
MOPS.VOEvent.Templates

VOEvent XML and human readable text templates.
"""
# XML templates
VOEVENT_TMPLT = '''<?xml version="1.0" encoding="utf-8"?>
<VOEvent 
    ivorn="ivo://mops.lsst.org/VOEvent#%s"
    role="observation"
    version="1.1" 
    xmlns="http://www.ivoa.net/xml/VOEvent/v1.1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.ivoa.net/xml/VOEvent/v1.1 http://www.ivoa.net/xml/VOEvent/v1.1">
  <!-- This document was generated by MOPS -->
  <Who>
    <AuthorIVORN>ivo://voevent.lsst.org/MOPS</AuthorIVORN>
    <Date>%s</Date>
  </Who>
  <WhereWhen>
    <!-- Detections -->
%s
    <!-- Orbit -->
%s
    <!-- Geocentric ephemerides -->
%s
  </WhereWhen>
  <Description>
      This VOEvent packet resulted from observations made at the Pan-STARRS PS1 facility and analyzed with MOPS.
  </Description>
</VOEvent>
'''

# Detection: mag, det_datetime, ra_deg, dec_deg
OBS_TMPLT = '''    <ObsDataLocation description="Observations" xmlns="http://www.ivoa.net/xml/STC/stc-v1.30.xsd">
      <ObservatoryLocation id="MOPS" type="simple" 
        href="ivo://STClib/Observatories#MOPS" />
      <ObservationLocation>
        <AstroCoords coord_system_id="UTC-ICRS-TOPO-VMAG">
          <ScalarCoordinate unit="mag" frame_id="Vmag">
            <Value>%.02f</Value>
          </ScalarCoordinate>
          <Time><TimeInstant><MJDTime>%f</MJDTime></TimeInstant></Time>
          <Position2D unit="deg">
            <Value2><C1>%f</C1><C2>%f</C2></Value2>
          </Position2D>
        </AstroCoords>
      </ObservationLocation>
    </ObsDataLocation>'''
ORBIT_TMPLT = '''    <ObsDataLocation description="Orbit" xmlns="http://www.ivoa.net/xml/STC/stc-v1.30.xsd">
      <ObservatoryLocation id="MOPS" type="simple" 
        href="ivo://STClib/Observatories#MOPS" />
      <ObservationLocation>
        <AstroCoords coord_system_id="TDB-ECLIPTIC-MOPS">
          <Time><TimeInstant><MJDTime>%f</MJDTime></TimeInstant></Time>
          <Orbit>
            <q unit="AU">%f</q>
            <e>%f</e>
            <i unit="deg">%f</i>
            <Node unit="deg">%f</Node>
            <Aop unit="deg">%f</Aop>
            <T><MJDTime>%f</MJDTime></T>
            <SRC>
              %s
            </SRC>
            <h_v>%s</h_v>
            <residuals>%s</residuals>
            <chiSq>%s</chiSq>
            <convCode>%s</convCode>
            <moid1>%s</moid1>
            <moid2>%s</moid2>
          </Orbit>
        </AstroCoords>
      </ObservationLocation>
    </ObsDataLocation>'''
EPHEM_TMPLT = '''    <ObsDataLocation description="Geocentric ephemerides" xmlns="http://www.ivoa.net/xml/STC/stc-v1.30.xsd">
      <ObservatoryLocation id="MOPS" type="simple" 
        href="ivo://STClib/Observatories#MOPS" />
      <ObservationLocation>
        <AstroCoords coord_system_id="UTC-ICRS-BARY-VMAG">
          <ScalarCoordinate unit="mag" frame_id="Vmag">
            <Value>%.02f</Value>
          </ScalarCoordinate>
          <Time><TimeInstant><MJDTime>%f</MJDTime></TimeInstant></Time>
          <Position2D unit="deg">
            <Value2><C1>%f</C1><C2>%f</C2></Value2>
            <Error2><C1>%s</C1><C2>%s</C2></Error2>
          </Position2D>
        </AstroCoords>
      </ObservationLocation>
    </ObsDataLocation>'''
SRC_TMPLT = '''<Value21>
                   <C01>%f</C01><C02>%f</C02><C03>%f</C03><C04>%f</C04><C05>%f</C05>
                   <C06>%f</C06><C07>%f</C07><C08>%f</C08><C09>%f</C09><C10>%f</C10>
                   <C11>%f</C11><C12>%f</C12><C13>%f</C13><C14>%f</C14><C15>%f</C15>
                   <C16>%f</C16><C17>%f</C17><C18>%f</C18><C19>%f</C19><C20>%f</C20>
                   <C21>%f</C21>
                 </Value21>'''

# Human readable templates
VOEVENT_TEXT_TMPLT = '''MOPS Event %s
This VOEvent packet resulted from observations made at the Pan-STARRS PS1 
facility and analyzed with MOPS.
Date: %s

Detections
mag, MJD, RA (deg), Dec (deg)
%s

Orbit
%s

Geocentric ephemerides
mag, MJD, RA (deg), Dec (deg), RAerr (deg), Decerr (deg)
%s
--------'''

# Detection: mag, det_datetime, ra_deg, dec_deg
OBS_TEXT_TMPLT = '''%.02f, %f, %f, %f'''
ORBIT_TEXT_TMPLT = '''Epoch (MJD) = %f
q (AU)      = %f
e           = %f
i (deg)     = %f
Node (deg)  = %f
Aop (deg)   = %f
Top (MJD)   = %f
SRC         = %s
h_v         = %s
residuals   = %s
chiSq       = %s
convCode    = %s
moid1       = %s
moid2       = %s'''
EPHEM_TEXT_TMPLT = '''%.02f, %f, %f, %f, %s, %s'''
SRC_TEXT_TMPLT = '%s'
