Skip to content

Instantly share code, notes, and snippets.

@agalasso
Created January 21, 2024 03:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agalasso/684419e13a00dedd5312d46009482564 to your computer and use it in GitHub Desktop.
Save agalasso/684419e13a00dedd5312d46009482564 to your computer and use it in GitHub Desktop.
ansvr developer notes

ansvr Developer Notes

ansvr is a wrapper around the astrometry.net plate solve command, solve-field. If your client program is on the same machine where astrometry.net/ansvr is installed, you should consider invoking solve-field directly as that is simpler and more efficient than going through the ansvr HTTP interface.

Using solve-field directly

If you put your image to be solved (stars.fit in the following example) in the folder %LOCALAPPDATA%\cygwin_ansvr\tmp\ then you can run:

%LOCALAPPDATA%\cygwin_ansvr\bin\bash.exe --login -c "/usr/bin/solve-field -p -O -U none -B none -R none -M none -N none -C cancel --crpix-center -z 2 --objs 100 -u arcsecperpix -L 1.3752 -H 1.5199 /tmp/stars.fit"

Replace the numbers after -L and -H with your low and high image scale estimates (arcsec per pixel). The solution will be in the file stars.wcs (FITS format). You can run solve-field --help to see all the available options.

Using the HTTP interface

If you do want to use the HTTP interface, here are some notes on the subset of the nova.astrometry.net Web API implemented by ansvr.

login request

Client request: POST /api/login Server response: JSON object:

  {
    "session": "SESSION_ID"
  }

subsequent requests from the client pass the session id

upload request

Client: POST /api/upload/ with Content-Type: multipart/form-data

The first part of the multipart/form-data request is the JSON request with the scale hint information. Example:

  {
    "session": "SESSION_ID",
    "allow_commercial_use": "d",
    "allow_modifications": "d",
    "publicly_visible": "y",
    "scale_units": "arcsecperpix",
    "scale_type": "ev",
    "scale_est": 1.2225129792992102,
    "scale_err": 100.0
  }

scale_est and scale_err are the key parameters; other parameters are ignored (except session). The image scale is expected to be between scale_est - scale_est*scale_err/100 and scale_est + scale_est*scale_err/100

The second part of the upload request is the image data (FITS file format)

submissions request

Client: POST /api/submissions/<SESSION_ID> Server: response is a JSON object containing a non-empty jobs list attribute and non-zero processing_finished numeric attribute when done, e.g.

  {
    "jobs": [
      "2"
    ],
    "processing_started": "1",
    "user": "0",
    "user_images": [
    ],
    "processing_finished": "1"
  }

Keep posting the submissions request periodically until the job has completed.

job status request

Client: POST /api/jobs/<JOB_ID> using the job id from the /api/submissions response Server: response contains a JSON object with the status of the solve (success/failure), e.g.

  {
    "status": "success"
  }

calibration request

Client: POST /api/jobs/<JOB_ID>/calibration Server: solution data as a JSON object:

  {
    "epoch": "J2000",
    "parity": 1,
    "pixscale": 1.432661730613,
    "radius": 0,
    "ra": 332.901073719,
    "orientation": 84.4399787598054,
    "dec": 12.8668742287
  }

Etc.

I have a perl module that works as an ansvr or nova.astrometry.net client that is available if anyone is interested, but if you use the command line interface (solve-field), then you won't need it. I'd be willing to develop other language bindings if there is any interest.

If you end up adding ansvr to your application, please drop me an email at andy.galasso@gmail.com. I am interested in hearing how ansvr is being used as this can help steer future development.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment