Changes made 10/29/92 - fft2d and fourn had HUGEFLOAT replaced with float cursor -can generate numbers marks - can echo commands for piping sky - no argument or help give syntax 11/11/92 move in Michaels 10/29/92 version of phot.c 11/17/92 add outfile to add,sub,mul,div. remove calls to exten in gphot, div, offxy, cursor, tv,mn 11/18/92 put image_save before image_wait in tv so garbage is cleaned up in expose. 11/20/92 fits.c modified to open fname.fts or fname (in that order) this allows files with non .fts extensions and ones with extra periods or strange paths to be opened. (Exten is replaced by strcat(). Also an error message is generated if the file exists but is write protected. 11/23/92 Aperint had sky floating and 2*chord not 2*chord+1 data point read in. 11/24/92 Write the 'impatch' program to do bilinear interpolation inside a box. Find a bug in smooth which moved the images by one row. ================== changes made by MWR 12/15/92 ========================= Replaced "gaussfit.c" and "gaussj.c", which contained routines for fitting a gaussian to data derived from Numerical Recipes, with my own "gaussFit.c". My routine is around 4x slower, but much more robust; it returns zero if a fit was found, and non-zero if not. It also does not require the convention of arrays going from (1,N) instead of (0,N-1), which should make use from "normal" C code much easier. The new function "gauss_fit()" is placed in the library "libvista.a" New version of STARS, which has a. new TINYSIZE=9 (old=13) b. MOVEMAX check to keep star from wandering c. extra array-bounds checks in do_stars() loop d. new, MWR gauss_fit call (instead of NR) e. no "normalization" before gauss_fit() call f. use gaussian FWHM rather than do_fwhm() if possible Modified AXES.C to use the new "gauss_fit()" function. Fixed minor bug in "compar()" in FITS.C. Changes to PHOT.C: a. fixed a sqrt() bug around line 411. b. now use fractional pixel values in the aperture sum, where fraction of value = fraction of pixel which lies within circle centered on stellar centroid (NOT necessary a pixel center). Modified the CURSOR, BOX and CIRCLE states in "image.c" so that they all allow a sliding colormap, just like the normal TV state. Removed "%u" unsigned format from HIST and SKY in favor of %d, since we DO have signed integers. Also, increased NHIST to 65536. Wrote a new version of SKY program to find sky-sigma by fitting a gaussian to histogram - much faster than computing it directly. It is currently in "newsky.c", and there's an entry in "makefile" to create a program "newsky." I'd like your feedback - occasionally, the old version is better; certainly it's more robust. Updated "makefile" somewhat, getting rid of dead stuff and adding "pstar" (as well as a temporary entry for "newsky"). Updated the PHOT and AXES man pages, and wrote a man page for CURSOR. Added support for BSCALE and BZERO in FITS.C. ========================= end of MWR 12/15/92 changes Xvista5 ================================================== 12/04/92 Write an `implant` command to generate montages 12/09/92 Modify pstar to add field switch also make nophoton as default Also the stars are now specified by peak not integrated counts. 12/10/92 Modify marks so that .coo and .pht files are the default. Also allows to specify filename on the command line, and skip headers in this mode. (Headers are assumed to have non blank space in column 1). 12/17/92 makefile: added-implant dropped-newsky fits.c: bscale and bzero changed newsky.c --> sky.c and sky.c is dropped sky.man revised to reflect bin sky.c changed so skysig has fewer digits. stars.c: added maxstars keyword .man updated phot.c: avoid taking log (-counts) XVISTA5================================================== 12/28/92 stars.c - removed exten() autospan.c - fixed bug in compar() and changed NDARTS 12/29/92 marks.c - buffers size changed from NBUF --> BIG_BUF 2/22/93 write an abx.man page (for no particular reason ) 3/24/93 fft2d.c added complex input 3/24/93 profile.c added encircled energy function 3/24/93 fft2d.man, sky.man profile.man 4/27/93 div.c fix bug in illegal option 2/28/93 fits.c MWR get_next_handle bug fixed 3/19/93 profile.c eef function added -rrt 3/19/93 fft2d.c eef function added -rrt 5/13/93 flip.c add outfile option -rrt 5/13/93 remove gphot and offxy 5/13/93 rotate.c - remove lagrange and sinc options 5/13/93 many man pages modified. 5/19/93 add xplot.c 06/01/93 modify fits.c for underflow bug 6/28/93 modify xplot.c to accept xsixty and ysixty 7/05/93 modify fits.c get_symbol so it will retrieve longer symbols 7/8/93 pcvista.h: NMAX raised to 4096 7/19/93 xplot.c get_col added so more columns can be read 7/21/93 xplot.c add optional delay to connect command 7/22/93 mash.c add box option. 7/23/93 cursor.c add quiet flag 7/28/93 clip.c add outfile and verbose option ------------ XVista6 -------------------------- 8/4/93 Treatment of BSCALE/BZERO changed fits.c -fits_copyheader() added fits.h - fits_copyheader() added add.c, div.c impatch.c implant.c,median.c mul.c sub.c,window.c modified to use this. copyheader.c -deleted pfits.c - default width changed from 8 to 5 pstar.c - add grid option tv.c - modify error message 8/6/93 buffers.c - keywords converted to upper case 8/18/93 xplot.c limits now takes '-' to specify use previous limit. 8/19/93 smooth.c - add smooth: to error message 8/24/93 axes.c - exp.c argument truncated for bad values pstar.c - photon noise not treated correctly for gain!=1.0 10/29/93 xplot.c - add wait function 11/17/93 marks.c - add progname to stderr calls 2/11/93 fits.c - allow reading of BITPIX=8 data 2/11/93 makeim.c - converts columnar data into images. ************ XVista7 2/25/94 fft2d.c - nr.h placed after math.h 3/2/94 let.c - if symbol does not exist .. dont print it 4/20/94 autospan.c - INT_MAX --> RAND_MAX as needed 4/20/94 usleep.c - added for System V configurations 4/20/94 pstar.c - RAND_MAX changes. 4/22/94 nr.h--> ournr.h with some instances of float converted to double. This affects the routines four1,fft1d 4/22/94 put read/set_property into image1.c and remove it from cursor.c/propiniti.c this also required moving atom_state and atom_actual to extern. profile.c had a typo in the structure definition. 7/7/94 add unistd.h to many things that needed exit() prototype generate stars.h to link together .c needed by stars only 8/15/94 phot.c add exit(0) 9/22/94 mn.c add circle feature and make output key= 11/22/94 fold - write also fix bug that pix only worked in columns hist.c combined with histlib and circle incorporated. abx.c modified to allow circles 9/27/94 makeim modified. 9/28/94 sky.c allows circles and has keyword=value output. 10/13/94 increase number of allowed data points in fft1d and xplot 10/17/94 fft1d - skip lines with # in column 1 10/18/94 stars - add timeout option 11/03/94 implant - increase maximum number of files 11/09/94 fft1d - num= now instest of n= 11/22/94 fold write 7// Xplot - add wait function 7/17/95 smooth.c prototyping forced 7/18/95 phot.c increase APER_SIZE 7/25/95 xplot.c add hardcopy ************* modifications by Michael Richmond ********************** 9/27/95 - replace "usleep" with "vista_usleep", which calls a system version (if one exists), or runs a fake version if not. - add LINUX cpp flag, in preparation for LINUX-required changes - replace "bzero" with "bzeroe" in fits.c to avoid conflict with the symbol "bzero" in /usr/include/string.h - insert alternate call to "ftruncate" to 'getsym.c' for LINUX - replace "-g" with "-O" in CFLAGS (because I don't have the shared libraries needed to compile math library -g) - remove "strlen" calls in "compar" in 'fits.c' -- tests made with old XVista showed that this sped up the 'fits_open' call considerably for files with large headers. - added "*.o" to list of things to be removed in "make clean" - replaced "X" with "XLIBS" as a macro in Makefile, and placed it _after_ libivista.a in link line - Note to myself: "xvista8.tar" is Dick's archive "MWRVista.tar" is my current working copy - move "makefile" to "Makefile" - move all .man files into "man1" directory 10/31/95 - place the "matherr" function in axes.c into #ifndef LINUX, since I can't find the LINUX equivalent - cleaning up man pages: up to box.1 11/1/95 - cleaning up man pages, up to circle.1. - trouble! looks like "evaluate" isn't working. Why? - Oh. Needed to fix lots of stuff in XVista lib source code. Almost done ... image.c and image1.c still need much work. 11/5/95 - Fixed up image.c: defined macros to detect bad return values from a couple of X11 functions. - Added "-lvista" to link line for xplot, for "vista_usleep" 11/11/95 - fixing warnings and errors in all code ... up to convert.c - see "err" for remaining errors - also noticed a couple of days ago that TV takes a long, long time to display an image under X11 on this machine. Try to speed up? 11/12/95 - main reason that TV is slow is the scaling of data, before we send it to X_fill. - modified TV to use a pixel_value->intensity lookup table, which is calculated once only; this is faster than calculating intensity value for every pixel, since that involves a multiplication for every pixel. Can now display a 768x640 image in about 8 seconds. 11/13/95 - added "fold" to the Makefile EXECS macro. Note that "fold" is apparently also a Linux command, unfortunately. - continuing to fix up man pages: up to fold.1. - modified "hardcopy" command in XPLOT to take a filename for Postscript output, rather than "noprint". 11/20/95 - up to "hist.1" man page - running "hist" on 512x512 image of M51 called "foo.fts" takes a very long time: 20.81u 520.54sys 9:56elapsed 90%CPU - I must improve performance of histogram routines! - tests show my machine VERY slow on any floating-point calculation. No way to avoid calc'ing cumulative percentage when writing output histogram. However, fixed other sections so that it reaches the output-writing routine after 10-15 seconds on 512x512 image foo.fts. Now "time" output looks like 19.89u 247.22sys 4:49elapsed 92%CPU 11/26/95 - by removing consecutive entries for zero from output histogram file, reduce times on "foo.fts" to 5.57u 38.32sys 0:45elapsed 96%CPU - removed "sinc" and "lagrange" from usage line of 'imshift' since they are not currently implemented - re-wrote MAKEIM so that it requires the user to specify both NROW and NCOL in the new image. - up to "makeim.1" on the man pages. 1/5/96 - put new motherboard into computer, AMD DX4-120. - now when I run "hist foo.fts", I get times 0.52u 0.56sys 0:02elapsed 58%CPU Much faster! - It appears that "stars ... show" doesn't display crosshairs, and "marks" doesn't, either. Uh oh. 1/8/96 - in image.c, modified "do_crosshair" to use 'copygc' instead of 'rubber_gc'. - in image.c, modified "show_number" to use 'copygc' instead of 'rubber_gc' - up to 'mn.1' on the man pages - added 'help' option to 'median' and 'mn' - would be nice to make add/sub/div/mul allow user to specify 'circle=' as well as 'box=' - added 'help' option to mulvec. - added 'help' option to pfits. - added 'help' option to phot, and made 'help' output appear on several lines, like that of stars - added 'help' option to profile - added 'help' option to pstar - fixed compiler warnings for rotate added 'help' option. - fixed the man page for "sky", which seriously out of date - removed the 'file=' option in "smooth", which a) wasn't implemented b) is done by the new "ring" program, anyway - put 'smooth' and 'rotate' into the Makefile EXECS list - up to "smooth.1" in man pages. 1/10/96 - added 'help' option to stars - added 'help' option to sub - added 'help' option to subvec - added 'help' option to tv - added 'help' option to window - up to "xplot" in man pages -- Done! But I have to make a second pass to add 'help' options to all files I missed in the first pass. :-( 1/13/96 - modified "axes" program in several ways. It was occasionally having segmentation faults. a) now subtract sky value from all pixels, then perform calculations. It causes round-off to integer pixel values, but simplifies code. b) re-wrote "do_fwhm" to be robust. Now no longer seems to seg fault at the drop of a hat. 1/22/96 - added "help" option to add - added "help" option to addvec - fixed "help" option to axes - added "help" option to bin - added "help" option to buffers - added "help" option to clip - added "help" option to comment - added "help" option to convert - modifed "help" message in cursor - added "help" option to div - added "help" option to divvec - modified "help" message in fft1d - modified "help" message in fft2d - modified "help" option in flip - modified "help" option in fold 1/23/96 - I ought to modify "sky" to use fitted gaussian peak for the sky value, not the peak of the histogram - added "help" option to hist - added "help" option to impatch - added "help" option to implant - added "help" option to imshift - added "help" option to let 1/24/96 - added "help" to makeim - added "help" option to mash - added "help" option to xplot; also made "help" command prompt user for more, if message is long 1/25/96 - inserted new program "ring"; I wrote it a few months ago at work and hadn't brought it into XVista8 yet. - discovered that a "file=" option for "smooth" would be useful after all, or some means by which the user could specify a kernel himself. Put this on the Wish List. 1/29/96 - fixed bug in "fits_cut" -- can't call "truncate", because that requires closing the FILE. Instead, find the "fileno" element of the FILE structure, and use it to call "ftruncate". 1/30/96 - need to speed up "pstar" by truncating PSF of stars at some point; currently, the program calculates the contribution of every star to every pixel in the image! Done. - increased MIN_CELL from 16 -> 32 in "image.c" - I discover that the FITS header routines take a VERY long time when I give 500 stars to "pstar". Why is that? Should be only an additional 14 or so FITS header units... Later ... no, it's not the fault of the FITS header routines. I'm not sure what is taking so long ... 2/19/96 - modify "sky.c" so that it uses a fitted gaussian to figure the sky value itself, as well as the sky-sigma. used to use the peak bin of the sky histogram as the sky. - modify "find_chisq" routine in "gaussFit.c" so that it checks to see if the user supplies a value "width=0" (which would lead to division by zero). If so, the routine re-sets "width" to a small positive value, to avoid the division by zero. 2/24/96 - copied over files "stars.c" -> "stars.c.new" and "star_gauss.c" > "star_gauss.c.new" from spiff, where I modified them last week. Tried to insert the new sections of code into existing "stars.c" and "star_gauss.c", but ended up failing to convolve images properly. Must figure this out later. 3/2/96 - problem with "stars" and 'convolve' option was that I was using too small an image to perform convolution properly, so all "edge" pixels were being set to zero. No problem there. - fixed a bug in "stars1.c" that allowed divide-by-zero and crash. - fixed a bug in "pstar.c": was incrementing nstar before using the value of s[nstar].width. - note that it takes 5:00 elapsed to compile and link all programs 3/3/96 - tried to finish translating FORTRAN code in "interp.c" into C. I can get code to compile, but a quick test shows that (at least some of it) doesn't work. Must check the "sinc" option of "imshift" for example. - 'lagrange' option in "interp.c" does seem to work, on the other hand 3/19/96 - fixed backwards usage of "row" and "col" keywords to 'addvec'. Did I get it right? 7/13/96 - tried compiling code on Sun Sparc IPX running SunOs 5.5, which led me to the following modifications: a. added "%ld" for pid_t type in printf: fits.c, adobe.c b. declared "hypot" as external double func if SUN defined c. added new macro in Makefile, XGETUNSIGNED. It should be set to 1 if the XGetWindowProperty function takes (unsigned char **) for its final argument (appropriate under Linux and new SunOs), or 0 if it takes (signed char **) (older SunOs). Changes to int_box.c, int_circle.c, marks.c, stars.c d. now check to make sure M_PI defined before we use it in pstar.c, rotate.c, xplot.c e. removed -static from one of the CFLAGS lines (not good for SunOs 5.5) - I noticed that the "xplot" program has a LOT of warning messages; it needs to be cleaned up. Also, when it starts up, the plot window is filled with garbage -- giving "erase" command is necessary - added "bin=" option to SKY program. This will help when reducing TASS data, which has big quantization effects. 7/28/96 - fixed a bug in "init_lut" in tv.c that caused display to show only two colors when requested span was smaller than number of available display intensity levels (i.e. when span < cspan). - in image.c, functions "box_size_handle" and "circle_size_handle", made "cr" and "cc" into static variables. 8/1/96 - remove conversion to lower case in "store_window", in windman.c - added "live" option to "tv" - added "spawn" routine to "xplot" - added README files to all subdirectories, and main directory - added TASS.example C-shell script with example use of XVista - added lots of comments to Makefile - wrote new README file (changed this file's name to CHANGES) 8/3/96 - made some changes required to display images successfully on Linux system in Vermont (RedHat and Metro X): modified image.c to adapt to situation if numcells < MIN_CELL modified image.c to use copygc in calls to XDrawImageString - upgraded code I modified on the train ride up: axes.c: add a "negative reflection" for all points in profile gaussFit.c: decreased MAXITER 200 -> 20, changed some DEBUG lines 8/13/96 - took main calculation routine "do_axes" out of "axes.c" and put it into "do_axes.c", which is now part of the library - if "gauss_fit" routine doesn't converge, it now returns the values obtained during the final iteration; used to return -1. 8/15/96 - fixed subtle bug in "set_greyscale" -- I _think_ that it sets colormap properly now! - modified find_sky in image1.c so that it uses median sky value, rather than a mean sky value. Makes a difference in crowded fields, but this ought to be an option? 8/18/96 - split up "xplot.c" into 2 files: xplot.c a small driver that takes input from user and calls functions in XPLOT library xplotlib.c library of many functions, which are placed into "libxplot.a" I haven't tested all the functions yet to make sure that they all work .... MWR 8/19/96 - Inserted some XPLOT commands into the "image1.c" routine "do_profile_key", so that the same process that controls the image window also controls an XPLOT window. Seems to work pretty well. Requires that the "tv" program link in the new "xplotlib" library. 8/20/96 - in "do_zoom" (image1.c), replaced "execl" by "execlp", so that the path to the "tv" command is grabbed from the environment. Old version would work when executed within XVISTA directory, but not otherwise. 8/24/96 - moved functions from "ournr.h" to "pcvista.h" - created "distr" target in Makefile (which removes all FFT stuff from distribution package) - placed 'Copyright' banners at top of all .c and .h files - added RELEASE file, containing concise info on latest release ------------------ distribution alpha XVista9A ------------------------- 8/24/96 - added a "fits_close" in do_zoom in image1.c, bug appeared only rarely 8/26/96 - modified "do_axes.c" so that "do_axes" uses ONLY those pixels within 'fitrad' of the center of the box to calculate the centroid and fitted gaussian ... but uses all pixels in the box for second moments. - modified "do_axes" so that, if eigenvalues yield sqrt(negative) then set eccentricity=0.0 (rather than crashing) 8/30/96 - in "tv", when user presses "a" key for aperture photometry, program now uses a box of length 2*(aperture_radius*2) to compute centroid; used to use fixed box size - removed "fits_open/fits_close" pair of lines from do_zoom; was causing problems, and serving no useful purpose - in "fits.h", change value of FITS_FAIL macro from 0 to -1, since 0 is a valid handle. - add "npix" to list of items printed by aperture key in "tv" 10/22/96 - added undocumented "falsecolor" option to "tv" command (may never document this, since it's pretty useless) - improved the cleaning up after we have plotting radial profiles now no longer leave little files in /tmp directory 11/18/96 - modified "convert" program to take number of rows and cols from the command line, instead of reading them from the input file itself. 2/21/97 - minor fixes to xplotlib.c to improve performance when we run a command file - added new command "ccdvec" to perform simultaneous dark-subtraction and flatfielding without losing any precision. Helps when reducing drift-scan data. 2/23/97 - changed method of calculating sky value in "phot" program now use (binned) median by default 3/16/97 - added #define CLIPNEGATIVE to star_gauss.c. If defined, the "apply_gaussian" routine (invoked when STARS run with "convolve" option) will replace any negative values in the convolved version of an image with zeroes. This helps the centroiding routine to avoid failing wildly. - updated the "phot" man page, to reflect new options in measuring sky background (should have done this 2/23/97) 4/12/97 - fixed bug in "implant" which over-wrote one column more than it should have. 4/18/97 - made "hist" program slightly more robust --- doesn't crash when given negative pixel values 5/28/97 - modify "do_aperture_key" in "image1.c" so that, if we can't calculate the centroid of an object at which the user is pointing, warn him, and then use the cursor position as the center for an aperture magnitude measurement 5/30/97 - modify "xplotlib.c", "xplotlib.h", "xplot.c" to add a new argument to the "xplot_event()" function. This allows us to wait for the user to press a button, and then read the value of the cursor, from within another user program. 6/3/97 - fixed bug in "fits.c" which could screw up END line in FITS header if we just added a new line to the header. 9/1/97 - added SWAPBYTES option in Makefile; it appears to be necessary on the RedHat 4.2 Linux system running on a Pentium Pro in my office at RIT. The SWAPBYTES option activates #ifdef'd code sections in fits.c which swap the bytes on each read/write from/to a FITS file. 12/16/97 - fixed calculation of second moments of a peak in star_axes() function of "star1.c". Also removed unused "HUGE" #define. 6/14/98 - fixed bug in "tv.c" that binned data improperly. Could lead to a crash due to bad memory reference for large bin factors. 4/18/99 - fixed bug in "image1.c", in function "do_zoom". Was incorrectly calculating the boundaries of zoom box. 4/25/99 - added new feature to image display: if one pressed "c" key while image is displayed, one gets a curve-of-growth in circular apertures centered on the star nearest cursor. Use the symbol table values curveofg_npoints how many radii are there? curveofg_r1 radius of aperture 1 (pixels) curveofg_r2 radius of aperture 2 (pixels) etc. The sky-subtracted flux inside each aperture is divided by the sky-subtracted flux in largest aperture, and fractions are printed to the standard output. 2/10/01 - changed the type of "main()" in just about all executable programs from "void" to "int". We were already calling "exit" with arg 0 for these programs. - added "int" in a few places where variables were declared without a type; e.g. "static flag;" 2/11/01 - re-wrote "putsym()" function in "getsym.c". The old version could cause a seg fault if the symbol table didn't yet exist; it also looked very dangerous, opening the same file twice simultaneously. The new version should be much safer, but does A) hold all symbol information in memory briefly B) explicitly truncate all lines at 78 characters 3/8/2001 - fixed bug in "phot.c" in the "do_phot()" function. Was using an inaccurate count of pixels within each aperture, because we were counting fractional pixels as whole ones. This causes noise estimates to be too large, yielding uncertainties in each magnitude measurement which were too large. 5/20/2001 - changed the way we deal with fractional pixels at the edges of synthetic aperture in 'phot.c'. We used to use a linear approximation to the fraction which fell inside aperture. Now we break each pixel into 100x100 subpixels and count. Is more accurate, but a bit slower. 5/21/2001 - added 'iqm' = 'InterQuartile Mean' option to "median.c"; gives option of calculating interquartile mean instead of true median, which helps to avoid spikes in the distribution of pixel values. - modified "sky.c" so that it passes information to the gaussian- fitting routine differently. It makes a histogram of pixel values near the sky value. It used to give as the x-coord to the gauss fitter (pixel value) - (-32767) which meant that a typical image with a sky value around 3000 ADU would have x-coord values of around 36000. The gauss-fitter uses an initial step size of 10% of the initial value when searching for best peak position, so that meant that the step size was 3600 ADU! Much, much to coarse a search to find the peak accurately. Now, we give as x-coord to the gauss fitter (pixel value) - (starting pixel value near peak) which means that the x-coord values start at 1 and go up to 100 or so, for a typical image. The initial step size is thus a few ADU, which is reasonable. 5/27/2001 - wrote new 'mask' program, which searches for groups of connected bad pixels in an image. It can be used on a flatfield image to find ice crystals or other defects. - Modified "phot.c" in two ways: 1. added 'maskfile=' option to 'phot.c'. As each star is measured, the 'phot' program will check to see if it lies close to a known bad region. If so, it will set the quality flag appropriately. 2. We no longer set the uncertainty in magntiude to a negative number to indicate possible saturation. Instead, we now print an extra column at the end of each line, the "quality flag". This can indicate saturation, and/or "close to edge", and/or "close to bad region." 7/23/2001 - modified "do_aperture_key" routine in image1.c so that it uses the "aperture_radius" value as the fitting radius to fit a gaussian to the radial profile. 7/28/2001 - added new command "sbig2fits", which converts SBIG "uncompressed" images to FITS format. It's not a general-purpose tool, but designed to work just well enough to deal with images taken at the RIT Observatory with our SBIG ST-8. 10/15/2001- changed "MAXADD" in add.c from 10 -> 100, so that we can co-add LOTS of frames. 7/16/2002 - modified 'find_sky' in image1.c so that it uses interquartile mean instead of median to find sky value when user presses one of the interactive 'tv' keys 2/16/2003 - new "back" program to fit and (optionally) subtract a low-order polynomial fit to sky background 2/23/2003 - added #include lines to most source code files to placate compiler warning messages; a few are left, but they aren't my fault - removed the "find_sky" routine from the "sky.c" file, since it now takes the routine from a library