include "../lib/xphot.h" include "../lib/objects.h" include "../lib/center.h" include "../lib/fitsky.h" include "../lib/phot.h" # XP_PLMEAS -- Procedure to execute the sky fitting task measuring commands. pointer procedure xp_plmeas (gd, xp, im, ol, rl, gl, key, wx, wy, oxver, oyver, nover, sxver, syver, nsver) pointer gd # pointer to the graphics stream pointer xp # pointer to the aperture photometry descriptor pointer im # the image descriptor int ol # the input object list descriptor int rl # the results list descriptor int gl # the output objects list descriptor int key # the cursor keystroke real wx, wy # the cursor coordinates real oxver[ARB] # the current object polygon x vertices real oyver[ARB] # the current object polygon y vertices int nover # the number of object vertices real sxver[ARB] # the current sky polygon x vertices real syver[ARB] # the current sky polygon y vertices int nsver # the number of sky vertices int nobjs, object, nextobject, cier, sier, pier pointer sp, imname, olname, rlname, str, symbol, pstatus real wxlist, wylist int xp_robjects(), stnsymbols(), xp_nextobject(), xp_prevobject() int xp_fobject(), xp_fitcenter(), xp_ofitsky(), xp_magp(), xp_stati() pointer stfind(), xp_statp() real xp_statr() begin call smark (sp) call salloc (imname, SZ_FNAME, TY_CHAR) call salloc (olname, SZ_FNAME, TY_CHAR) call salloc (rlname, SZ_FNAME, TY_CHAR) call salloc (str, SZ_FNAME, TY_CHAR) call xp_stats (xp, IMAGE, Memc[imname], SZ_FNAME) call xp_stats (xp, OBJECTS, Memc[olname], SZ_FNAME) call xp_stats (xp, RESULTS, Memc[rlname], SZ_FNAME) pstatus = xp_statp(xp,PSTATUS) object = OBJNO(pstatus) # Read the objects file. if (Memc[olname] == EOS) { #call printf ("Warning: The current objects file is undefined\n") } else if (ol == NULL) { #call printf ("Warning: Cannot open current objects file (%s)\n") #call pargstr (Memc[olname]) } else if (xp_statp (xp, OBJLIST) == NULL) { nobjs = xp_robjects (ol, xp, RLIST_NEW) if (nobjs <= 0) { call printf ( "Warning: The current objects file (%s) is empty\n") call pargstr (Memc[olname]) } else { call printf ("Read %d objects from current objects file %s\n") call pargi (nobjs) call pargstr (Memc[olname]) } } switch (key) { # Move around the objects lists measuring objects. case 'o', '-', '.': if (im == NULL) { call printf ("Warning: Cannot open current image (%s)\n") call pargstr (Memc[imname]) nextobject = 0 } else if (xp_statp (xp, OBJLIST) == NULL) { call printf ("Warning: The current object list is empty\n") nextobject = 0 } else if (stnsymbols (xp_statp(xp, OBJLIST), 0) <= 0) { call printf ("Warning: The current object list is empty\n") nextobject = 0 } else if (key == 'o') { if (xp_nextobject (xp, object) == EOF) { call printf ( "Warning: The current objects list is at EOF\n") nextobject = 0 } else nextobject = object } else if (key == '-') { if (xp_prevobject (xp, object) == BOF) { call printf ( "Warning: The current objects list is at BOF\n") nextobject = 0 } else nextobject = object } else if (key == '.') { nextobject = xp_fobject (xp, wx, wy, wxlist, wylist) if (nextobject <= 0) { call printf ( "Warning: Marked object not in current object list\n") } else object = nextobject } if (nextobject > 0) { call gim_setraster (gd, 1) call sprintf (Memc[str], SZ_FNAME, "objlist%d") call pargi (nextobject) symbol = stfind (xp_statp(xp, OBJLIST), Memc[str]) call gscur (gd, XP_OXINIT(symbol), XP_OYINIT(symbol)) call gim_setraster (gd, 0) wxlist = XP_OXINIT(symbol) wylist = XP_OYINIT(symbol) cier = xp_fitcenter (xp, im, wxlist, wylist) sier = xp_ofitsky (xp, im, symbol, xp_statr (xp, XSHIFT), xp_statr (xp, YSHIFT), sxver, syver, nsver, NULL, NULL) pier = xp_magp (xp, im, symbol, xp_statr (xp, XSHIFT), xp_statr (xp, YSHIFT), oxver, oyver, nover, xp_statr(xp, SKY_MODE), xp_statr(xp, SKY_STDEV), xp_stati (xp, NSKY)) call xp_oamark (gd, xp, symbol, oxver, oyver, nover, sxver, syver, nsver, 1, 1) call gdeactivate (gd, 0) call xp_pqprint (xp, Memc[imname], cier, sier, pier, LOGRESULTS(pstatus)) call greactivate (gd, 0) if (rl != NULL && LOGRESULTS(pstatus) == YES) { SEQNO(pstatus) = SEQNO(pstatus) + 1 call xp_pwrite (xp, rl, SEQNO(pstatus), Memc[olname], nextobject, cier, sier, pier) } NEWCBUF(pstatus) = NO; NEWCENTER(pstatus) = NO NEWSBUF(pstatus) = NO; NEWSKY(pstatus) = NO NEWMBUF(pstatus) = NO; NEWMAG(pstatus) = NO wx = wxlist; wy = wylist } else symbol = NULL # Fit sky for the current and all remaining objects case '+', '#': symbol = NULL if (im == NULL) { call printf ("Warning: Cannot open image (%s)\n") call pargstr (Memc[imname]) } else if (xp_statp (xp, OBJLIST) == NULL) { call printf ("Warning: The current objects list is empty\n") } else if (stnsymbols (xp_statp(xp,OBJLIST),0) <= 0) { call printf ("Warning: The current objects list is empty\n") } else if (key == '+' && object == EOF) { call printf ("Warning: The current objects list is at EOF\n") } else { call flush (STDOUT) if (object == BOF || key == '#') nextobject = 0 else nextobject = object nobjs = 0 while (xp_nextobject (xp, nextobject) != EOF) { call sprintf (Memc[str], SZ_FNAME, "objlist%d") call pargi (nextobject) symbol = stfind (xp_statp(xp,OBJLIST), Memc[str]) wxlist = XP_OXINIT(symbol) wylist = XP_OYINIT(symbol) cier = xp_fitcenter (xp, im, wxlist, wylist) sier = xp_ofitsky (xp, im, symbol, xp_statr (xp, XSHIFT), xp_statr (xp, YSHIFT), sxver, syver, nsver, NULL, NULL) pier = xp_magp (xp, im, symbol, xp_statr (xp, XSHIFT), xp_statr (xp, YSHIFT), oxver, oyver, nover, xp_statr(xp, SKY_MODE), xp_statr(xp, SKY_STDEV), xp_stati (xp, NSKY)) if (rl != NULL && LOGRESULTS(pstatus) == YES) { SEQNO(pstatus) = SEQNO(pstatus) + 1 call xp_pwrite (xp, rl, SEQNO(pstatus), Memc[olname], nextobject, cier, sier, pier) } call xp_oamark (gd, xp, symbol, oxver, oyver, nover, sxver, syver, nsver, 1, 1) wx = wxlist; wy = wylist nobjs = nobjs + 1 } if (rl != NULL && LOGRESULTS(pstatus) == YES) { call printf ( "Wrote %d detected and measured list objects to file %s\n") call pargi (nobjs) call pargstr (Memc[rlname]) } else { call printf ("Detected and measured %d list objects\n") call pargi (nobjs) } object = EOF NEWCBUF(pstatus) = NO; NEWCENTER(pstatus) = NO NEWSBUF(pstatus) = NO; NEWSKY(pstatus) = NO NEWMBUF(pstatus) = NO; NEWMAG(pstatus) = NO #call greactivate (gd, 0) } default: symbol = NULL call printf ("Ambiguous or undefined keystroke command\n") } OBJNO(pstatus) = object call sfree (sp) return (symbol) end # XP_PMEAS -- Procedure to execute the sky fitting task measuring commands. pointer procedure xp_pmeas (gd, xp, im, rl, gl, key, wx, wy, oxver, oyver, nover, sxver, syver, nsver) pointer gd # pointer to the graphics stream pointer xp # pointer to the aperture photometry descriptor pointer im # the image descriptor int rl # the results list descriptor int gl # the output objects list descriptor int key # the cursor keystroke real wx, wy # the cursor coordinates real oxver[ARB] # the current object polygon x vertices real oyver[ARB] # the current object polygon y vertices int nover # the number of object vertices real sxver[ARB] # the current sky polygon x vertices real syver[ARB] # the current sky polygon y vertices int nsver # the number of sky vertices int wcs, cier, sier, pier, nobjs real swx, swy pointer sp, imname, rlname, str, pstatus int xp_stati(), clgcur(), xp_cfit1(), xp_sfit1(), xp_mag1(), xp_aphot() pointer xp_statp() real xp_statr() begin call smark (sp) call salloc (imname, SZ_FNAME, TY_CHAR) call salloc (rlname, SZ_FNAME, TY_CHAR) call salloc (str, SZ_FNAME, TY_CHAR) call xp_stats (xp, IMAGE, Memc[imname], SZ_FNAME) call xp_stats (xp, RESULTS, Memc[rlname], SZ_FNAME) pstatus = xp_statp(xp,PSTATUS) switch (key) { # Measure and object near the cursor. case ' ': # Measure. if (im != NULL) { if ((xp_stati (xp, PGEOMETRY) == XP_APOLYGON && nover < 3) || (xp_stati(xp,SGEOMETRY) == XP_SPOLYGON && nsver < 3)) { call printf ("Sky or photometry polygon is undefined\n") } else { cier = xp_cfit1 (xp, im, wx, wy, NEWCBUF(pstatus), NEWCENTER(pstatus), cier) if (xp_stati(xp, SMODE) == XP_SCONCENTRIC) sier = xp_sfit1 (xp, im, xp_statr (xp, XCENTER), xp_statr (xp, YCENTER), sxver, syver, nsver, NULL, gd, NEWSBUF(pstatus), NEWSKY(pstatus)) else { # Get the offset sky position. if (xp_stati(xp, SALGORITHM) != XP_CONSTANT && xp_stati(xp, SALGORITHM) != XP_ZERO && xp_stati(xp,SALGORITHM) != XP_SKYFILE) { call printf ("Again for sky:\n") if (clgcur ("gcommands", swx, swy, wcs, key, Memc[str], SZ_LINE) == EOF) ; } sier = xp_sfit1 (xp, im, swx, swy, sxver, syver, nsver, NULL, gd, NEWSBUF(pstatus), NEWSKY(pstatus)) } pier = xp_mag1 (xp, im, xp_statr (xp, XCENTER), xp_statr (xp, YCENTER), oxver, oyver, nover, xp_statr (xp, SKY_MODE), xp_statr (xp, SKY_STDEV), xp_stati (xp, NSKY), NEWMBUF(pstatus), NEWMAG(pstatus)) call xp_amark (gd, xp, oxver, oyver, nover, sxver, syver, nsver, 1, 1) call gdeactivate (gd, 0) call xp_pqprint (xp, Memc[imname], cier, sier, pier, LOGRESULTS(pstatus)) call greactivate (gd, 0) if (rl != NULL && LOGRESULTS(pstatus) == YES) { SEQNO(pstatus) = SEQNO(pstatus) + 1 call xp_pwrite (xp, rl, SEQNO(pstatus), "none", 0, cier, sier, pier) } NEWCBUF(pstatus) = NO; NEWCENTER(pstatus) = NO NEWSBUF(pstatus) = NO; NEWSKY(pstatus) = NO NEWMBUF(pstatus) = NO; NEWMAG(pstatus) = NO } } else { call printf ("Warning: Cannot open image (%s)\n") call pargstr (Memc[imname]) } # Automatically detect and measure a list of objects. case '*': if (rl != NULL && LOGRESULTS(pstatus) == YES) { nobjs = xp_aphot (gd, im, rl, xp, NO) call printf ( "Wrote %d detected and measured objects to file %s\n") call pargi (nobjs) call pargstr (Memc[rlname]) } else { nobjs = xp_aphot (gd, im, NULL, xp, NO) call printf ("Detected and measured %d objects\n") call pargi (nobjs) } default: call printf ("Ambiguous or undefined keystroke command\n") } call sfree (sp) return (NULL) end