int plot_radec_plot(const char* command, cairo_t* cairo, plot_args_t* pargs, void* baton) { plotradec_t* args = (plotradec_t*)baton; // Plot it! rd_t myrd; rd_t* rd = NULL; //rd_t* freerd = NULL; int Nrd; int i; if (!pargs->wcs) { ERROR("plotting radec but not plot_wcs has been set."); return -1; } if (args->fn && dl_size(args->radecvals)) { ERROR("Can only plot one of rdlist filename and radec_vals"); return -1; } if (!args->fn && !dl_size(args->radecvals)) { ERROR("Neither rdlist filename nor radec_vals given!"); return -1; } plotstuff_builtin_apply(cairo, pargs); rd = get_rd(args, &myrd); if (!rd) return -1; Nrd = rd_n(rd); // If N is specified, apply it as a max. if (args->nobjs) Nrd = MIN(Nrd, args->nobjs); // Plot markers. for (i=args->firstobj; i<Nrd; i++) { double x,y; double ra = rd_getra(rd, i); double dec = rd_getdec(rd, i); if (!plotstuff_radec2xy(pargs, ra, dec, &x, &y)) continue; if (!plotstuff_marker_in_bounds(pargs, x, y)) continue; plotstuff_stack_marker(pargs, x-1, y-1); } plotstuff_plot_stack(pargs, cairo); if (rd != &myrd) rd_free(rd); //rd_free(freerd); return 0; }
int plot_annotations_plot(const char* cmd, cairo_t* cairo, plot_args_t* pargs, void* baton) { plotann_t* ann = (plotann_t*)baton; // Set fonts, etc, before calling plotting routines plotstuff_builtin_apply(cairo, pargs); if (ann->NGC) plot_ngc(cairo, pargs, ann); if (ann->bright) plot_brightstars(cairo, pargs, ann); if (ann->HD) plot_hd(cairo, pargs, ann); if (ann->constellations) plot_constellations(cairo, pargs, ann); if (bl_size(ann->targets)) plot_targets(cairo, pargs, ann); return plotstuff_plot_stack(pargs, cairo); }
int plot_xy_plot(const char* command, cairo_t* cairo, plot_args_t* pargs, void* baton) { plotxy_t* args = (plotxy_t*)baton; // Plot it! xylist_t* xyls; starxy_t myxy; starxy_t* xy = NULL; starxy_t* freexy = NULL; int Nxy; int i; #if 0 double t0; #endif plotstuff_builtin_apply(cairo, pargs); if (args->fn && dl_size(args->xyvals)) { ERROR("Can only plot one of xylist filename and xy_vals"); return -1; } if (!args->fn && !dl_size(args->xyvals)) { ERROR("Neither xylist filename nor xy_vals given!"); return -1; } if (args->fn) { #if 0 t0 = timenow(); #endif // Open xylist. xyls = xylist_open(args->fn); if (!xyls) { ERROR("Failed to open xylist from file \"%s\"", args->fn); return -1; } // we don't care about FLUX and BACKGROUND columns. xylist_set_include_flux(xyls, FALSE); xylist_set_include_background(xyls, FALSE); if (args->xcol) xylist_set_xname(xyls, args->xcol); if (args->ycol) xylist_set_yname(xyls, args->ycol); // Find number of entries in xylist. xy = xylist_read_field_num(xyls, args->ext, NULL); freexy = xy; xylist_close(xyls); if (!xy) { ERROR("Failed to read FITS extension %i from file %s.\n", args->ext, args->fn); return -1; } Nxy = starxy_n(xy); // If N is specified, apply it as a max. if (args->nobjs) Nxy = MIN(Nxy, args->nobjs); //logmsg("%g s to read xylist\n", timenow()-t0); } else { assert(dl_size(args->xyvals)); starxy_from_dl(&myxy, args->xyvals, FALSE, FALSE); xy = &myxy; Nxy = starxy_n(xy); } // Transform through WCSes. if (args->wcs) { double ra, dec, x, y; assert(pargs->wcs); /* // check for any overlap. double pralo,prahi,pdeclo,pdechi; double ralo,rahi,declo,dechi; anwcs_get_radec_bounds(pargs->wcs, 100, &pralo, &prahi, &pdeclo, &pdechi); anwcs_get_radec_bounds(args->wcs, 100, &ralo, &rahi, &declo, &dechi); if ( */ for (i=0; i<Nxy; i++) { anwcs_pixelxy2radec(args->wcs, // I used to add 1 here starxy_getx(xy, i), starxy_gety(xy, i), &ra, &dec); if (!plotstuff_radec2xy(pargs, ra, dec, &x, &y)) continue; logverb(" xy (%g,%g) -> RA,Dec (%g,%g) -> plot xy (%g,%g)\n", starxy_getx(xy,i), starxy_gety(xy,i), ra, dec, x, y); // add shift and scale... // FIXME -- not clear that we want to do this here... /* starxy_setx(xy, i, args->scale * (x - args->xoff)); starxy_sety(xy, i, args->scale * (y - args->yoff)); starxy_setx(xy, i, x-1); starxy_sety(xy, i, y-1); */ // Output coords: FITS -> 0-indexed image starxy_setx(xy, i, x-1); starxy_sety(xy, i, y-1); } } else { // Shift and scale xylist entries. if (args->xoff != 0.0 || args->yoff != 0.0) { for (i=0; i<Nxy; i++) { starxy_setx(xy, i, starxy_getx(xy, i) - args->xoff); starxy_sety(xy, i, starxy_gety(xy, i) - args->yoff); } } if (args->scale != 1.0) { for (i=0; i<Nxy; i++) { starxy_setx(xy, i, args->scale * starxy_getx(xy, i)); starxy_sety(xy, i, args->scale * starxy_gety(xy, i)); } } } // Plot markers. #if 0 t0 = timenow(); #endif for (i=args->firstobj; i<Nxy; i++) { double x = starxy_getx(xy, i); double y = starxy_gety(xy, i); if (plotstuff_marker_in_bounds(pargs, x, y)) plotstuff_stack_marker(pargs, x, y); } plotstuff_plot_stack(pargs, cairo); //logmsg("%g s to plot xylist\n", timenow()-t0); starxy_free(freexy); return 0; }