Skip to content

Commit

Permalink
nova: add image-radec link to results page
Browse files Browse the repository at this point in the history
  • Loading branch information
nova committed Aug 20, 2024
1 parent 6699a04 commit 5ca3829
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
4 changes: 4 additions & 0 deletions net/templates/user_image/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ <h3>Calibration</h3>
<td>Stars detected in your images (x,y table):</td>
<td><a href="{% url 'axy-file' jobid=job.id %}">axy.fits</a></td>
</tr>
<tr>
<td>Stars detected in your images, converted to RA,Dec (FITS table):</td>
<td><a href="{% url 'image-rd-file' jobid=job.id %}">image-radec.fits</a></td>
</tr>
<tr>
<td>Correspondences between image and reference stars (table):</td>
<td><a href="{% url 'corr-file' jobid=job.id %}">corr.fits</a></td>
Expand Down
3 changes: 2 additions & 1 deletion net/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def dos_error(req):
index, index_tag, annotated_image, grid_image, index_location, index_nearby, index_recent, index_all, index_by_user,
index_user, index_album, hide, unhide, user_image, edit, search, serve_image, serve_thumbnail_image, image_set,
onthesky_image, sdss_image, galex_image, unwise_image, legacysurvey_image, red_green_image, extraction_image, wcs_file, new_fits_file,
kml_file, rdls_file, axy_file, corr_file)
kml_file, rdls_file, axy_file, image_rd_file, corr_file)
urlpatterns.extend([
re_path(r'^annotated_(?P<size>full|display)/(?P<jobid>' + jobpattern + r')/?', annotated_image, name='annotated_image'),
re_path(r'^grid_(?P<size>full|display)/(?P<jobid>' + jobpattern + r')/?', grid_image, name='grid_image'),
Expand Down Expand Up @@ -127,6 +127,7 @@ def dos_error(req):
re_path(r'^kml_file/(?P<jobid>' + idpattern + r')/?$', kml_file, name='kml-file'),
re_path(r'^rdls_file/(?P<jobid>' + idpattern + r')/?$', rdls_file, name='rdls-file'),
re_path(r'^axy_file/(?P<jobid>' + idpattern + r')/?$', axy_file, name='axy-file'),
re_path(r'^image_rd_file/(?P<jobid>' + idpattern + r')/?$', image_rd_file, name='image-rd-file'),
re_path(r'^corr_file/(?P<jobid>' + idpattern + r')/?$', corr_file, name='corr-file'),
])
#
Expand Down
25 changes: 25 additions & 0 deletions net/views/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,31 @@ def axy_file(req, jobid=None):
res['Content-Disposition'] = 'attachment; filename=axy.fits'
return res

def image_rd_file(req, jobid=None):
job = get_object_or_404(Job, pk=jobid)
wcsfn = job.get_wcs_file()
axyfn = job.get_axy_file()
rdfn = get_temp_file(tempfiles=req.tempfiles)
cmd = 'wcs-xy2rd -w %s -i %s -o %s' % (wcsfn, axyfn, rdfn)
logmsg('Running: ' + cmd)
(rtn, out, err) = run_command(cmd)
if rtn:
logmsg('out: ' + out)
logmsg('err: ' + err)
return HttpResponse('wcs-xy2rd failed: out ' + out + ', err ' + err)
from astrometry.util.fits import fits_table
xy = fits_table(axyfn)
rd = fits_table(rdfn)
for c in xy.get_columns():
rd.set(c, xy.get(c))
rd.writeto(rdfn)

res = HttpResponse(open(rdfn, 'rb'))
res['Content-Type'] = 'application/fits'
res['Content-Length'] = file_size(rdfn)
res['Content-Disposition'] = 'attachment; filename=image-radec.fits'
return res

def corr_file(req, jobid=None):
job = get_object_or_404(Job, pk=jobid)
f = open(job.get_corr_file(), 'rb')
Expand Down

0 comments on commit 5ca3829

Please sign in to comment.