{% extends "base.html" %}

{% block title %}Candidate {{transient.id}}{% endblock %}

{% block content %}

<body bgcolor="#424242" onload="TimerThread()">


<script type="text/javascript">
var a = new Image(); a.src = 'http://cas.sdss.org/astrodr7/en/tools/chart/navi.asp?ra={{ avg_coords.ra }}&dec={{ avg_coords.dec }}&scale=0.1&width=500&height=500&opt=GPS';
var b = new Image(); b.src = 'http://casjobs.sdss.org/ImgCutoutDR7/getjpeg.aspx?ra={{ avg_coords.ra }}&dec={{ avg_coords.dec }}&scale=0.1&width=500&height=500&opt=GPS';
</script>

<DIV CLASS="hover">
<CENTER>
<!-- <FONT size="6" color="white"><B>lists</B><FONT><BR> -->
<FONT size="4">
<A HREF="../../"><B>home</B></A>
<FONT color="white">|</FONT>
<A HREF="../../followup/2/"><B>good</B></A>
<FONT color="white">|</FONT>
<A HREF="../../followup/3/"><B>possible</B></A>
<FONT color="white">|</FONT>
<A HREF="../../followup/1/"><B>confirmed</B></A>
<FONT color="white">| </FONT>
<A HREF="../../followup/5/"><B>attic</B></A>
<FONT color="white">|</FONT>
<A HREF="../../followup/8/"><B>eyeball-fast-track</B></A>
<FONT color="white">|</FONT>
<A HREF="../../userlist/"><B>custom</B></A>
</FONT><BR>

</CENTER>
</DIV>
<HR>

<CENTER>
<TABLE><TR><th align="left">
<FONT color="#A9D0F5" size='5'><B>&nbsp Candidate: <FONT color="#FFFFFF">{{ transient.id }}</FONT> </B></FONT>

{% if transient.followup_id %}
<FONT color="#A9D0F5" size='5'><B>&nbsp Rank: <FONT color="#FFFFFF">{{ transient.followup_id }}</FONT> </B></FONT>
{% endif %}

{% if transient.followup_flag_date %}
<FONT color="#A9D0F5" size='5'><B>&nbsp Flag Date: <FONT color="#FFFFFF">{{ transient.followup_flag_date }}</FONT> </B></FONT>
{% endif %}

<BR>
{% if transient.local_designation %}
<FONT color="#A9D0F5" size='5'><B>&nbsp  QUB Designation: <FONT color="#FFFFFF">{{ transient.local_designation }}</FONT> </B></FONT>
{% endif %}

<BR>
{% if transient.ps1_designation %}
<FONT color="#A9D0F5" size='5'><B>&nbsp  PS1 Designation: <FONT color="#FFFFFF">{{ transient.ps1_designation }}</FONT> </B></FONT>
{% endif %}

<BR>
<FONT color="#A9D0F5" size='5'><B>&nbsp Classification: <FONT color="#FFFFFF">{{ transient.object_classification.description }}</FONT> </B></FONT>
<FONT color="#A9D0F5" size='5'><B>&nbsp Occurrences: <FONT color="#FFFFFF">{{ table.rows.count|add:"1" }}</FONT> </B></FONT>
<FONT color="#A9D0F5" size='5'><B>&nbsp Survey: <FONT color="#FFFFFF">{{ transient.tcs_cmf_metadata_id.filename|slice:"4" }}</FONT> </B></FONT>

<!-- RA and DEC taken from the second set of observations - would be good take these from the primary observation -->
<BR>
<FONT color="#A9D0F5" size='5'><B>&nbsp RA: <FONT color="#FFFFFF">{{ avg_coords.ra_sex }}</FONT> </B></FONT>
<FONT color="#A9D0F5" size='5'><B>&nbsp DEC: <FONT color="#FFFFFF">{{ avg_coords.dec_sex }}</FONT> </B></FONT>
<FONT color="#A9D0F5" size='5'><B>&nbsp List: <FONT color="#FFFFFF">{{ transient.detection_list_id.name }}</FONT> </B></FONT>
{% if transient.tcs_cmf_metadata_id.filename|slice:"4" == "FGSS"  %}
<FONT color="#A9D0F5" size='5'><B>&nbsp Object Crossmatch: <a href="http://star.pst.qub.ac.uk/ps/parts/SNcrossmatches.html#{{ transient.local_designation }}"><FONT color="#FFFFFF">check here</FONT></a> </B></FONT>
{% endif %}


{% if cfaMatch %}
<BR>
<FONT color="#A9D0F5" size='5'><B>&nbsp CfA ID: <a href="http://telescopes.rc.fas.harvard.edu/ps1/alerts2011{% if cfaMatch.eventID >= 300000 %}v3{% endif %}/{{cfaMatch.cfa_designation}}/{{cfaMatch.cfa_designation}}.html"><FONT color="#FFFFFF">{{ cfaMatch.cfa_designation|default_if_none:"" }}</FONT></a> </B></FONT>
{% endif %}

{% if transient.local_comments %}
<BR>
<FONT color="#A9D0F5" size='5'><B>&nbsp Comments: <FONT color="#FFFFFF" size='2'>{{ transient.local_comments }}</FONT> </B></FONT>
{% endif %}

{% if transient.observation_status %}
<BR>
<FONT color="#A9D0F5" size='5'><B>&nbsp Spectral Type: <FONT color="#FFFFFF" size='4'>{{ transient.observation_status }}</FONT> </B></FONT>
{% endif %}

</TR>


<!-- lightcurve and recurrence plot -->
<TR><th align="center">
<BR>
<TABLE height="500" cellpadding="0" cellspacing="0"><TR>
<TD cellpadding="0"> <a href="../../../site_media/images/lightcurves/{{transient.id}}_lc.jpeg"><img src="../../../site_media/images/lightcurves/{{transient.id}}_lc.jpeg" height="500"  BORDER="0"/></TD>
<TD cellpadding="0">
	<TABLE height="500" cellpadding="0" cellspacing="0">
	<TR style='vertical-align:top; padding:0px'><TD style='padding:0px'><a href="../../../site_media/images/recurrence_plots/{{transient.id}}_rp.png"><img src="../../../site_media/images/recurrence_plots/{{transient.id}}_rp.png" height="235"  BORDER="0"/></a></TD></TR>
	<TR><TD><FONT size="4" color="#FFFFFF">&#8656; &#8657; &#8659; click to zoom</FONT></TD></TR>
	<TR style='vertical-align:bottom;  padding:0px'><TD style='padding:0px'><a href="../../../site_media/images/location_maps/{{transient.id}}_np.png"><img src="../../../site_media/images/location_maps/{{transient.id}}_np.png" height="235"  BORDER="0" /></a></TD>
</TR></TABLE>

</TR><TR><TD>
<FORM name="Boxes" onsubmit="0" color="#A9D0F5">
<FONT color="#A9D0F5" size='4'><B>&nbsp Current MJD : <FONT color="#FFFFFF"><INPUT name="row2d" size="28" value="just a sec ..." style="color: #FFFFFF;  border:0; font-family:helvetica; font-weight: bold; font-style: normal; font-size:14pt; background-color: #424242"></FONT> </B></FONT>
</FORM><TD>

</TR></TABLE>
</CENTER>


<!-- 2012-03-26 KWS Add new ConeSearch results -->
{% if conesearchresults %}
  <CENTER>
  <BR />
  <FONT color="#A9D0F5" size='5'><B> Other PS1 Objects in the Vicinity </B></FONT>
  <BR />
  <BR />

  <TABLE border="1" cellpadding="5" bgcolor="white">
  <tr>
    <th>PS1 Object ID</th>
    <th>Separation</th>
  </tr>

  {% for row in conesearchresults %}
    <tr>
    <td><a href="../{{row.xmid}}/">{{ row.xmid }}</a></td>
    <td>{{ row.separation|floatformat:2 }}&quot;</td>
    </tr>

  {% endfor %}

  </TABLE>

  <BR />
  <BR />
  </CENTER>
{% endif %}



<!-- Plot new lightcurve, flux and forced photometry -->
<CENTER>

<FONT color="#A9D0F5" size='2'>Lightcurve Data <a href="../../lightcurve/{{transient.id}}/"> here</a></FONT>

</CENTER>

<BR><BR>

<!-- Plot new lightcurve, flux and forced photometry -->
<CENTER>

<FONT color="#A9D0F5" size='5'><B>Lightcurve replotting options: <a href="../../lightcurves/{{transient.id}}/"> here</a> </B></FONT>

</CENTER>

</TABLE>

<BR><BR>

<!-- Data table -->
{% ifnotequal table.rows.count 0 %}
<CENTER>
<TABLE border="1" cellpadding="5" bgcolor="white">
<tr>
  {% for column in table.columns %}
  <th>
    {% if column.sortable %}
      <a href="?sort={{ column.name_toggled }}">
        {{ column }}
      </a>
      {% if column.is_ordered_reverse %}
        <!-- <img src="../../../site_media/images/up.jpg" /> -->
      {% else %}
        <!-- <img src="../../../site_media/images/down.jpg" /> -->
      {% endif %}
    {% else %}
      {{ column }}
    {% endif %}
  </th>
  {% endfor %}
</tr>

{% for row in table.rows %}
  <tr>
  <td>{{ row.data.imageid }}</td>
  <td>{{ row.data.mjd_obs|floatformat:3 }}</td>
  <td>{{ row.data.ra_sex }}</td>
  <td>{{ row.data.dec_sex }}</td>
  <td>{{ row.data.psf_inst_mag|floatformat:3 }}</td>
  <td>{{ row.data.ap_mag|floatformat:3 }}</td>
  <td>{{ row.data.cal_psf_mag|floatformat:3}}</td>
  <td>{{ row.data.filter }}</td>
  <td>{{ row.data.cmf_file }}</td>
  <td>{{ row.data.image }}</td>
  </tr>

{% endfor %}

</TABLE>
{% endifnotequal %}
<BR>

{% if crossmatches.0.z %}
<BR>
<FONT color="#A9D0F5" size='5'><B> Possible Associations </B></FONT>
<BR>
<TABLE border="1" cellpadding="5" bgcolor="white">
  <td><FONT color="#3399FF" size='1'><B>Catalogue</B></FONT></td>
  <td><FONT color="#3399FF" size='1'><B>ID</B></FONT></td>
  <td><FONT color="#3399FF" size='1'><B>Separation</B></FONT></td>
  <td><FONT color="#3399FF" size='1'><B>z</B></FONT></td>
  <td><FONT color="#3399FF" size='1'><B>Distance (Mpc)</B></FONT></td>
  <td><FONT color="#3399FF" size='1'><B>(m-M)</B></FONT></td>
  <td><FONT color="#3399FF" size='1'><B>Distance Scale (Kpc/arcsec)</B></FONT></td>
  
{% for row in crossmatches %}
  <tr>
  <td><FONT size='1'>{{ row.catalogue_table_id.description }}</FONT></td>
  <td><FONT size='1'>{{ row.catalogue_object_id }}</FONT></td>
  <td><FONT size='1'>{{ row.separation|floatformat:2 }}"</FONT></td>
  <td><FONT size='1'>{{ row.z|floatformat:3 }}</FONT></td>
  <td><FONT size='1'>{{ row.distance|floatformat:2 }}</FONT></td>
  <td><FONT size='1'>{{ row.distance_modulus|floatformat:3 }}</FONT></td>
  <td><FONT size='1'>{{ row.scale|floatformat:2 }}</FONT></td>
  </tr>
{% endfor %}
</TABLE>
<BR><BR>
{% endif %}




<!-- Stamps, external data & possible associations -->
<TABLE><TR style='vertical-align:top'><TD>
{% if images %}
  <TABLE class="images">
  <TR>
  {% for image in images %}
     {% ifchanged image.image_group_id %}
        </TR><TR>
     {% endifchanged %}
     <TD>
     <FONT color="#FFFFFF" size="2">
     {{ image.image_type }}
     {% if image.filter %}
     ({{ image.filter }})
     {% endif %}
     <BR>
     mjd: {{ image.stamp_mjd|floatformat:5 }}<BR>
     </FONT>
     <!-- {% if image.pss_filename %}
     <FONT color="#FFFFFF" size="2">
     {{ image.pss_filename }}<BR>
     </FONT>
     {% endif %}-->

     <a href="../../../site_media/images/data/{{ image.filename }}.fits">
     <img src="../../../site_media/images/data/{{ image.filename }}.jpeg" alt="{{ image.pss_filename }}" title="{{ image.pss_filename }}" onerror="this.src='../../../site_media/images/image_not_available.jpeg';" {% if transient.tcs_cmf_metadata_id.filename|slice:"4" != "FGSS"  %} height="250" {% endif %} />
     </a><BR>
     </TD>
  {% endfor %}
  </TR>
  </TABLE>
{% endif %}
</TD>

<TD align="top">
<TABLE border="1" cellpadding="5" align="center" style="border: 3px #FFFFFF solid">
<tr align="center"><td>
<!-- possible associations -->

{% if transient.object_classification.flag_id > 1 or transient.tcs_cmf_metadata_id.filename|slice:"4" == "FGSS" %}
<TABLE border="1" cellpadding="5" bgcolor="white">

{% if not crossmatches.0.z %}
<FONT color="#A9D0F5" size='5'><B> Possible Associations </B></FONT>
<BR>

  {% if transient.tcs_cmf_metadata_id.filename|slice:"4" == "FGSS"  %}
    <td><FONT color="#3399FF" size='1'><B>SDSS ID</B></FONT></td>
    <td><FONT color="#3399FF" size='1'><B>Separation</B></FONT></td>
    <td><FONT color="#3399FF" size='1'><B>Assoc Type</B></FONT></td>
    <td><FONT color="#3399FF" size='1'><B>Obj Type</B></FONT></td>
    <td><FONT color="#3399FF" size='1'><B>g</B></FONT></td>
    <td><FONT color="#3399FF" size='1'><B>r</B></FONT></td>
    <td><FONT color="#3399FF" size='1'><B>i</B></FONT></td>
    <td><FONT color="#3399FF" size='1'><B>z</B></FONT></td>
    
    {% for row in crossmatches %}
      <tr>
      <td><FONT size='1'>{{ row.catalogue_object_id }}</FONT></td>
      <td><FONT size='1'>{{ row.separation|floatformat:2 }}"</FONT></td>
      <td><FONT size='1'>{{ row.association_type }}</FONT></td>
      <td><FONT size='1'>{{ row.type }}</FONT></td>
      <td><FONT size='1'>{{ row.g_|floatformat:2 }}</FONT></td>
      <td><FONT size='1'>{{ row.r_|floatformat:2 }}</FONT></td>
      <td><FONT size='1'>{{ row.i_|floatformat:2 }}</FONT></td>
      <td><FONT size='1'>{{ row.z_|floatformat:2 }}</FONT></td>
      </tr>
    {% endfor %}

  {% else %}
    <td><FONT color="#3399FF" size='1'><B>Catalogue</B></FONT></td>
    <td><FONT color="#3399FF" size='1'><B>ID</B></FONT></td>
    <td><FONT color="#3399FF" size='1'><B>Separation</B></FONT></td>
  
    {% for row in crossmatches %}
      <tr>
      <td><font size='1'>{{ row.catalogue_table_id.description }}</FONT></td>
      <td><font size='1'>{{ row.catalogue_object_id }}</FONT></td>
      <td><font size='1'>{{ row.separation|floatformat:2 }}"</FONT></td>
      </tr>
    {% endfor %}
  {% endif %}

{% endif %}

</TABLE>
<BR><BR>
{% endif %}



<FONT color="#A9D0F5" size='5'><B> External Information </B></FONT>
<BR>
<script type='text/javascript'
   src='http://wikisky.org/js/skywindow2'></script>
<div style='position:relative;left:0px;top:0px;{% if transient.tcs_cmf_metadata_id.filename|slice:"4" == "FGSS"  %}width:500px;height:500px{% else %}width:400px;height:400px{% endif %}'>
<DIV id='mySkyWnd'
  style='position:absolute;left:0;top:0;{% if transient.tcs_cmf_metadata_id.filename|slice:"4" == "FGSS"  %}width:500px;height:500px{% else %}width:400px;height:400px{% endif %};overflow:hidden;border:0px solid gray'
  onmouseout='hideddrivetip();'></DIV></div>
<script type="text/javascript">

<!-- NEED TO INPUT RA (DECIMAL HOURS) HERE -->

var options = {ra:{{ transient.ra_in_hours }}, de:{{ avg_coords.dec }}, initZoom:6, {% if transient.tcs_cmf_metadata_id.filename|slice:"4" == "FGSS"  %}zoom:11{% else %}zoom:12{% endif %},
  survey:"", imgSource:"DSS2", allowTopPanel:true, showTopPanel:true, showRightPanel:true,
  allowMove:false, allowZoom:false,
  showPanZoomControl:true, panZoomControlLeft:6, panZoomControlTop:10,
  showScale:true, showStatus:false, showPosition:true, showStickers:false, showLabels:false,
  jpegQuality:0.8,
  showGrid:false, showOverlayGrid:false,
  showConstLines:false, showOverlayConstLines:false,
  showConstBoundaries:false, showOverlayConstBoundaries:false,
  showConstNames:false, showOverlayConstNames:false,
  showGalaxies:false, showOverlayGalaxies:false,
  showStars:false, showOverlayStars:false,
  buffer:1, moveTime:2000, smoothMoveAccelerationTime:500,
  posColor:"lightgray",posFontSize:"8pt",posFontWeight:"normal",posFontFamily:"verdana",
  scaleMaxLen:90, scaleHeight:6, scaleColor:"lightgray", scaleLineWidth:1
};
new SkyWindow2(options).attach($('mySkyWnd'));
</script>
<BR><BR>

<a href="http://cas.sdss.org/astrodr7/en/tools/chart/navi.asp?ra={{ avg_coords.ra }}&dec={{ avg_coords.dec }}&scale={% if transient.tcs_cmf_metadata_id.filename|slice:"4" == "FGSS"  %}0.2{% else %}0.1{% endif %}&width=500&height=500&opt=GPS" onmouseover="document.images['s1a'].src='http://casjobs.sdss.org/ImgCutoutDR7/getjpeg.aspx?ra={{ avg_coords.ra }}&dec={{ avg_coords.dec}}&scale={% if transient.tcs_cmf_metadata_id.filename|slice:"4" == "FGSS"  %}0.2{% else %}0.1{% endif %}&width=500&height=500&opt=GPSI';" onmouseout="document.images['s1a'].src='http://casjobs.sdss.org/ImgCutoutDR7/getjpeg.aspx?ra={{ avg_coords.ra}}&dec={{avg_coords.dec }}&scale={% if transient.tcs_cmf_metadata_id.filename|slice:"4" == "FGSS"  %}0.2{% else %}0.1{% endif %}&width=500&height=500&opt=GPS';">
<img src="http://casjobs.sdss.org/ImgCutoutDR7/getjpeg.aspx?ra={{ avg_coords.ra }}&dec={{ avg_coords.dec}}&scale={% if transient.tcs_cmf_metadata_id.filename|slice:"4" == "FGSS"  %}0.2{% else %}0.1{% endif %}&width=500&height=500&opt=GPS" name="s1a" {% if transient.tcs_cmf_metadata_id.filename|slice:"4" == "FGSS"  %} height="500" width="500" {% else %} height="400" width="400" {% endif %} alt="" border="0"></a>

<BR><BR><FONT size='3'>
<!-- WIKISKY --> <!-- NEED TO INPUT RA (DECIMAL HOURS) HERE x 2-->
<a href="http://www.wikisky.org/?ra={{ transient.ra_in_hours }}&de={{ avg_coords.dec }}&zoom=13&show_grid=1&show_constellation_lines=1&show_constellation_boundaries=1&show_const_names=0&show_galaxies=1&show_box=1&box_ra={{ transient.ra_in_hours }}&box_de={{ avg_coords.dec }}&box_width=50&box_height=50&img_source=DSS2" target="blank">WIKISKY</a><BR>

<!-- SDSS NAVIGATE LINK -->
<a href="http://cas.sdss.org/astrodr7/en/tools/chart/navi.asp?ra={{ avg_coords.ra }}&dec={{ avg_coords.dec }}&scale=0.1&width=500&height=500&opt=GPS" target="blank">SDSS Navigate</a><BR>

<!--SDSS NEAREST OBJECT (EXPLORE TOOL) -->
<a href="http://cas.sdss.org/astrodr7/en/tools/explore/obj.asp?ra={{ avg_coords.ra }}&dec={{ avg_coords.dec }}" target="blank">SDSS Nearest Object</a><BR>

<!-- SDSS Stripe 82 -->
<a href="http://cas.sdss.org/stripe82/en/tools/chart/navi.asp?ra={{ avg_coords.ra }}&dec={{ avg_coords.dec }}&scale=0.1&width=500&height=500&opt=GPS" target="blank">SDSS Stripe 82</a><BR>

<!-- NED LINK -->
<a href="http://nedwww.ipac.caltech.edu/cgi-bin/nph-objsearch?in_csys=Equatorial&in_equinox=J2000.0&lon={{ avg_coords.ra|floatformat:6 }}d&lat={{ avg_coords.dec|floatformat:6 }}d&radius=0.16667&hconst=73&omegam=0.27&omegav=0.73&corr_z=1&z_constraint=Unconstrained&z_value1=&z_value2=&z_unit=z&search_type=Near+Position+Search&ot_include=ANY&nmp_op=ANY&out_csys=Equatorial&out_equinox=J2000.0&obj_sort=Distance+to+search+center&of=pre_text&zv_breaker=30000.0&list_limit=5&img_stamp=YES" target="_blank">NED : 10 arcsec radius</a><BR>

<!-- LEDA -->
<a href="http://leda.univ-lyon1.fr/fG.cgi?n=0&c=o&p=J{{ avg_coords.ra }}d{{ avg_coords.dec }}d&f=0.16667&ob=ra" target="blank">LEDA : 10 arcsec radius</a><BR>

<!-- SIMBAD -->
<a href="http://simbad.u-strasbg.fr/simbad/sim-coo?Coord={{avg_coords.ra}}d{{ avg_coords.dec }}d&Radius=10&Radius.unit=arcsec&CooFrame=FK5&CooEqui=2000&CooEpoch=2000" target="blank">SIMBAD : 10 arcsec radius</a><BR>

<!-- Galactic Extinction -->
<a href="http://nedwww.ipac.caltech.edu/cgi-bin/nph-calc?in_csys=Equatorial&in_equinox=J2000.0&obs_epoch=2000.0&lon={{ avg_coords.ra }}d&lat={{ avg_coords.dec }}d&pa=0.0&out_csys=Equatorial&out_equinox=J2000.0" target="blank">Galactic Extinction</a><BR>
<BR></FONT>
</TD></TR>
</TABLE>
</TD></TR>
</TABLE>
<!-- </TABLE> -->
<BR>

</CENTER>

<!-- 2011-04-04 KWS Added the User Defined Lists -->

<CENTER>

{% if userList %}
<BR>
<TABLE class="userlists">
   <TR>
      <TH>Object is a member of:</TH>
   </TR>
   {% for row in userList %}
   <TR>
      <TD><a href="../../userlist/{{row.object_group_id.id}}/">{{ row.object_group_id.description }}</a></TD>
   </TR>
   {% endfor %}
<TABLE>
<BR>
<BR>
<BR>
{% endif %}

</CENTER>

<CENTER>

<!-- 2011-10-04 KWS Removed the ifnotequal for list = 0 - i.e. allow form for Garbage objects now -->

{% if transient.detection_list_id.id >= 0 %}
   {% if form %}
   {% if form.errors %}
       <p style="color: red;">
           Please correct the error{{ form.errors|pluralize }} below.
       </p>
   {% endif %}

   <form action="" method="post">{% csrf_token %}
   <FONT color="#FFFFFF">
   <TABLE class="forms">
       {{ form.as_table }}
   </TABLE>
   <BR>
   <input type="submit" value="Update Object" />
   </FONT>
   </form>
   {% endif %}
{% endif %}

</CENTER>


{% endblock %}

