Changeset 36680 for branches/eam_branches/ps2-tc3-20130727/Ohana
- Timestamp:
- Apr 21, 2014, 5:42:34 AM (12 years ago)
- Location:
- branches/eam_branches/ps2-tc3-20130727
- Files:
-
- 164 edited
- 40 copied
-
. (modified) (1 prop)
-
Ohana (modified) (1 prop)
-
Ohana/src/addstar/src/GetFileMode.c (modified) (1 diff)
-
Ohana/src/addstar/src/LoadDataPMM.c (modified) (1 diff)
-
Ohana/src/addstar/src/ReadStarsSDSS.c (modified) (1 diff)
-
Ohana/src/addstar/src/fakeimage.c (modified) (2 diffs)
-
Ohana/src/addstar/src/find_matches.c (modified) (1 diff)
-
Ohana/src/addstar/src/find_matches_closest.c (modified) (1 diff)
-
Ohana/src/addstar/src/find_matches_closest_refstars.c (modified) (1 diff)
-
Ohana/src/addstar/src/find_matches_refstars.c (modified) (1 diff)
-
Ohana/src/addstar/src/findskycell.c (modified) (10 diffs)
-
Ohana/src/addstar/src/loadsupercos_plates.c (modified) (1 diff)
-
Ohana/src/addstar/src/sky_tessalation.c (modified) (1 diff)
-
Ohana/src/dvomerge (modified) (1 prop)
-
Ohana/src/dvomerge/src/dvo_image_merge_dbs.c (modified) (1 diff)
-
Ohana/src/dvomerge/src/dvomergeUpdate.c (modified) (2 diffs)
-
Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c (modified) (4 diffs)
-
Ohana/src/dvomerge/src/dvoverify_args.c (modified) (1 diff)
-
Ohana/src/dvomerge/src/dvoverify_catalogs.c (modified) (1 diff)
-
Ohana/src/dvomerge/src/dvoverify_utils.c (modified) (1 diff)
-
Ohana/src/dvomerge/src/merge_catalogs_old.c (modified) (1 diff)
-
Ohana/src/dvopsps/include/dvopsps.h (modified) (2 diffs)
-
Ohana/src/dvopsps/src/initialize_dvopsps.c (modified) (4 diffs)
-
Ohana/src/dvopsps/src/insert_detections_dvopsps.c (modified) (1 diff)
-
Ohana/src/dvopsps/src/insert_detections_dvopsps_catalog.c (modified) (5 diffs)
-
Ohana/src/fixcat/src/gcatstats.c (modified) (1 diff)
-
Ohana/src/gastro/src/gstars.c (modified) (1 diff)
-
Ohana/src/gastro2/src/coordtest.c (modified) (1 diff)
-
Ohana/src/gastro2/src/gstars2.c (modified) (1 diff)
-
Ohana/src/getstar/src/GetFileMode.c (modified) (1 diff)
-
Ohana/src/getstar/src/MatchImages.c (modified) (2 diffs)
-
Ohana/src/getstar/src/dvoImagesAtCoords.c (modified) (4 diffs)
-
Ohana/src/kapa2/include/constants.h (modified) (1 diff)
-
Ohana/src/kapa2/src/Graphs.c (modified) (1 diff)
-
Ohana/src/kapa2/src/Image.c (modified) (1 diff)
-
Ohana/src/kapa2/src/bDrawObjects.c (modified) (11 diffs)
-
Ohana/src/libdvo/Makefile (modified) (1 diff)
-
Ohana/src/libdvo/include/dvo.h (modified) (11 diffs)
-
Ohana/src/libdvo/include/dvodb.h (modified) (3 diffs)
-
Ohana/src/libdvo/src/BoundaryTree.c (modified) (4 diffs)
-
Ohana/src/libdvo/src/ImageMetadataSelection.c (modified) (2 diffs)
-
Ohana/src/libdvo/src/ImageSelection.c (modified) (1 diff)
-
Ohana/src/libdvo/src/RegionHostTable.c (copied) (copied from trunk/Ohana/src/libdvo/src/RegionHostTable.c )
-
Ohana/src/libdvo/src/TessellationTable.c (copied) (copied from trunk/Ohana/src/libdvo/src/TessellationTable.c )
-
Ohana/src/libdvo/src/coordops.c (modified) (2 diffs)
-
Ohana/src/libdvo/src/dbCheckStack.c (modified) (1 diff)
-
Ohana/src/libdvo/src/dbExtractAverages.c (modified) (4 diffs)
-
Ohana/src/libdvo/src/dbExtractMeasures.c (modified) (8 diffs)
-
Ohana/src/libdvo/src/dbFields.c (modified) (3 diffs)
-
Ohana/src/libdvo/src/dvo_catalog.c (modified) (2 diffs)
-
Ohana/src/libdvo/src/dvo_convert.c (modified) (2 diffs)
-
Ohana/src/libdvo/src/dvo_convert_PS1_V4.c (modified) (1 diff)
-
Ohana/src/libdvo/src/dvo_photcode_ops.c (modified) (6 diffs)
-
Ohana/src/libdvo/src/dvo_tiny_values.c (modified) (2 diffs)
-
Ohana/src/libdvo/src/dvosorts.c (modified) (1 diff)
-
Ohana/src/libfits/table/F_get_column.c (modified) (1 diff)
-
Ohana/src/libkapa/src/IOfuncs.c (modified) (2 diffs)
-
Ohana/src/libkapa/src/KapaWindow.c (modified) (1 diff)
-
Ohana/src/libkapa/src/bDrawFuncs.c (modified) (2 diffs)
-
Ohana/src/libohana/src (modified) (1 prop)
-
Ohana/src/libohana/src/gaussj.c (modified) (3 diffs)
-
Ohana/src/markrock/src/gcatstats.c (modified) (1 diff)
-
Ohana/src/markstar/src/gcatstats.c (modified) (1 diff)
-
Ohana/src/mosastro/src/warptest.c (modified) (1 diff)
-
Ohana/src/opihi (modified) (1 prop)
-
Ohana/src/opihi/cmd.astro (modified) (1 prop)
-
Ohana/src/opihi/cmd.astro/Makefile (modified) (2 diffs)
-
Ohana/src/opihi/cmd.astro/cdensify.c (copied) (copied from trunk/Ohana/src/opihi/cmd.astro/cdensify.c )
-
Ohana/src/opihi/cmd.astro/fitplx.c (modified) (6 diffs)
-
Ohana/src/opihi/cmd.astro/fitpm.c (copied) (copied from trunk/Ohana/src/opihi/cmd.astro/fitpm.c )
-
Ohana/src/opihi/cmd.astro/gauss.c (modified) (3 diffs)
-
Ohana/src/opihi/cmd.astro/init.c (modified) (4 diffs)
-
Ohana/src/opihi/cmd.astro/region.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.astro/sersic.c (copied) (copied from trunk/Ohana/src/opihi/cmd.astro/sersic.c )
-
Ohana/src/opihi/cmd.astro/star.c (modified) (2 diffs)
-
Ohana/src/opihi/cmd.basic/list.c (modified) (10 diffs)
-
Ohana/src/opihi/cmd.data (modified) (1 prop)
-
Ohana/src/opihi/cmd.data/Makefile (modified) (4 diffs)
-
Ohana/src/opihi/cmd.data/cast.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/cast.c )
-
Ohana/src/opihi/cmd.data/densify.c (modified) (5 diffs)
-
Ohana/src/opihi/cmd.data/impeaks.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/impeaks.c )
-
Ohana/src/opihi/cmd.data/imsmooth.2d.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/imsmooth.2d.c )
-
Ohana/src/opihi/cmd.data/imsmooth.generic.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/imsmooth.generic.c )
-
Ohana/src/opihi/cmd.data/init.c (modified) (8 diffs)
-
Ohana/src/opihi/cmd.data/join.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/join.c )
-
Ohana/src/opihi/cmd.data/match2d.c (modified) (3 diffs)
-
Ohana/src/opihi/cmd.data/medimage.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/medimage.c )
-
Ohana/src/opihi/cmd.data/medimage_commands.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/medimage_commands.c )
-
Ohana/src/opihi/cmd.data/read_vectors.c (modified) (3 diffs)
-
Ohana/src/opihi/cmd.data/rebin.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.data/test/join.sh (copied) (copied from trunk/Ohana/src/opihi/cmd.data/test/join.sh )
-
Ohana/src/opihi/cmd.data/test/medimage.sh (copied) (copied from trunk/Ohana/src/opihi/cmd.data/test/medimage.sh )
-
Ohana/src/opihi/cmd.data/vellipse.c (modified) (1 diff)
-
Ohana/src/opihi/cmd.data/vgauss.c (modified) (2 diffs)
-
Ohana/src/opihi/cmd.data/vlist.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/vlist.c )
-
Ohana/src/opihi/dvo/Makefile (modified) (1 diff)
-
Ohana/src/opihi/dvo/avmatch.c (modified) (3 diffs)
-
Ohana/src/opihi/dvo/coordimage.c (copied) (copied from trunk/Ohana/src/opihi/dvo/coordimage.c )
-
Ohana/src/opihi/dvo/dvo_client.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/find_matches.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/gimages.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/hosts.c (modified) (3 diffs)
-
Ohana/src/opihi/dvo/init.c (modified) (2 diffs)
-
Ohana/src/opihi/dvo/photometry.c (modified) (2 diffs)
-
Ohana/src/opihi/dvo/showtile.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/simage.c (modified) (1 diff)
-
Ohana/src/opihi/include/data.h (modified) (4 diffs)
-
Ohana/src/opihi/include/dvomath.h (modified) (2 diffs)
-
Ohana/src/opihi/include/pantasks.h (modified) (2 diffs)
-
Ohana/src/opihi/include/pcontrol.h (modified) (3 diffs)
-
Ohana/src/opihi/lib.data/Makefile (modified) (1 diff)
-
Ohana/src/opihi/lib.data/MedImageOps.c (copied) (copied from trunk/Ohana/src/opihi/lib.data/MedImageOps.c )
-
Ohana/src/opihi/lib.data/starfuncs.c (modified) (2 diffs)
-
Ohana/src/opihi/lib.shell/ListOps.c (modified) (1 diff)
-
Ohana/src/opihi/lib.shell/check_stack.c (modified) (5 diffs)
-
Ohana/src/opihi/lib.shell/convert_to_RPN.c (modified) (6 diffs)
-
Ohana/src/opihi/lib.shell/dvomath.c (modified) (1 diff)
-
Ohana/src/opihi/lib.shell/evaluate_stack.c (modified) (7 diffs)
-
Ohana/src/opihi/lib.shell/stack_math.c (modified) (62 diffs)
-
Ohana/src/opihi/pantasks/CheckController.c (modified) (2 diffs)
-
Ohana/src/opihi/pantasks/ControllerOps.c (modified) (1 diff)
-
Ohana/src/opihi/pantasks/JobOps.c (modified) (1 diff)
-
Ohana/src/opihi/pantasks/LocalJob.c (modified) (1 diff)
-
Ohana/src/opihi/pantasks/TaskOps.c (modified) (1 diff)
-
Ohana/src/opihi/pantasks/init.c (modified) (1 diff)
-
Ohana/src/opihi/pantasks/init_server.c (modified) (1 diff)
-
Ohana/src/opihi/pantasks/task_nice.c (modified) (2 diffs)
-
Ohana/src/opihi/pclient/job.c (modified) (2 diffs)
-
Ohana/src/opihi/pcontrol/CheckBusyJob.c (modified) (1 diff)
-
Ohana/src/opihi/pcontrol/JobOps.c (modified) (3 diffs)
-
Ohana/src/opihi/pcontrol/StartJob.c (modified) (1 diff)
-
Ohana/src/opihi/pcontrol/job.c (modified) (4 diffs)
-
Ohana/src/opihi/pcontrol/jobstack.c (modified) (1 diff)
-
Ohana/src/opihi/pcontrol/status.c (modified) (4 diffs)
-
Ohana/src/photdbc/src/find_images.c (modified) (1 diff)
-
Ohana/src/photdbc/src/join_stars.c (modified) (1 diff)
-
Ohana/src/relastro/Makefile (modified) (1 diff)
-
Ohana/src/relastro/include/relastro.h (modified) (8 diffs)
-
Ohana/src/relastro/src (modified) (1 prop)
-
Ohana/src/relastro/src/ConfigInit.c (modified) (3 diffs)
-
Ohana/src/relastro/src/ImageOps.c (modified) (2 diffs)
-
Ohana/src/relastro/src/ImagePosIO.c (copied) (copied from trunk/Ohana/src/relastro/src/ImagePosIO.c )
-
Ohana/src/relastro/src/ImageTable.c (copied) (copied from trunk/Ohana/src/relastro/src/ImageTable.c )
-
Ohana/src/relastro/src/MeanPosIO.c (copied) (copied from trunk/Ohana/src/relastro/src/MeanPosIO.c )
-
Ohana/src/relastro/src/MosaicOps.c (modified) (8 diffs)
-
Ohana/src/relastro/src/StarMaps.c (modified) (1 diff)
-
Ohana/src/relastro/src/UpdateObjects.c (modified) (5 diffs)
-
Ohana/src/relastro/src/args.c (modified) (14 diffs)
-
Ohana/src/relastro/src/assign_images.c (copied) (copied from trunk/Ohana/src/relastro/src/assign_images.c )
-
Ohana/src/relastro/src/high_speed_objects.c (modified) (1 diff)
-
Ohana/src/relastro/src/hpm_objects.c (modified) (1 diff)
-
Ohana/src/relastro/src/indexCatalogs.c (copied) (copied from trunk/Ohana/src/relastro/src/indexCatalogs.c )
-
Ohana/src/relastro/src/initialize.c (modified) (1 diff)
-
Ohana/src/relastro/src/launch_region_hosts.c (copied) (copied from trunk/Ohana/src/relastro/src/launch_region_hosts.c )
-
Ohana/src/relastro/src/load_catalogs.c (modified) (2 diffs)
-
Ohana/src/relastro/src/load_images.c (modified) (3 diffs)
-
Ohana/src/relastro/src/markObjects.c (copied) (copied from trunk/Ohana/src/relastro/src/markObjects.c )
-
Ohana/src/relastro/src/relastro.c (modified) (1 diff)
-
Ohana/src/relastro/src/relastro_client.c (modified) (4 diffs)
-
Ohana/src/relastro/src/relastro_images.c (modified) (1 diff)
-
Ohana/src/relastro/src/relastro_objects.c (modified) (1 diff)
-
Ohana/src/relastro/src/relastro_parallel_images.c (copied) (copied from trunk/Ohana/src/relastro/src/relastro_parallel_images.c )
-
Ohana/src/relastro/src/relastro_parallel_regions.c (copied) (copied from trunk/Ohana/src/relastro/src/relastro_parallel_regions.c )
-
Ohana/src/relastro/src/resort_catalog.c (modified) (1 diff)
-
Ohana/src/relastro/src/select_images.c (modified) (5 diffs)
-
Ohana/src/relastro/src/share_images_pos.c (copied) (copied from trunk/Ohana/src/relastro/src/share_images_pos.c )
-
Ohana/src/relastro/src/share_mean_pos.c (copied) (copied from trunk/Ohana/src/relastro/src/share_mean_pos.c )
-
Ohana/src/relastro/src/syncfile.c (copied) (copied from trunk/Ohana/src/relastro/src/syncfile.c )
-
Ohana/src/relastro/src/testparallax.c (modified) (1 diff)
-
Ohana/src/relphot/Makefile (modified) (1 diff)
-
Ohana/src/relphot/doc/parallel.txt (modified) (1 diff)
-
Ohana/src/relphot/include/relphot.h (modified) (11 diffs)
-
Ohana/src/relphot/src/BoundaryTreeOps.c (modified) (2 diffs)
-
Ohana/src/relphot/src/BrightCatalog.c (modified) (9 diffs)
-
Ohana/src/relphot/src/ImageMagIO.c (copied) (copied from trunk/Ohana/src/relphot/src/ImageMagIO.c )
-
Ohana/src/relphot/src/ImageOps.c (modified) (11 diffs)
-
Ohana/src/relphot/src/ImageSubset.c (modified) (9 diffs)
-
Ohana/src/relphot/src/ImageTable.c (copied) (copied from trunk/Ohana/src/relphot/src/ImageTable.c )
-
Ohana/src/relphot/src/MeanMagIO.c (copied) (copied from trunk/Ohana/src/relphot/src/MeanMagIO.c )
-
Ohana/src/relphot/src/MosaicOps.c (modified) (5 diffs)
-
Ohana/src/relphot/src/StarOps.c (modified) (8 diffs)
-
Ohana/src/relphot/src/args.c (modified) (4 diffs)
-
Ohana/src/relphot/src/assign_images.c (copied) (copied from trunk/Ohana/src/relphot/src/assign_images.c )
-
Ohana/src/relphot/src/client_logger.c (modified) (2 diffs)
-
Ohana/src/relphot/src/help.c (modified) (2 diffs)
-
Ohana/src/relphot/src/indexCatalog.c (copied) (copied from trunk/Ohana/src/relphot/src/indexCatalog.c )
-
Ohana/src/relphot/src/initialize.c (modified) (2 diffs)
-
Ohana/src/relphot/src/launch_region_hosts.c (copied) (copied from trunk/Ohana/src/relphot/src/launch_region_hosts.c )
-
Ohana/src/relphot/src/load_catalogs.c (modified) (3 diffs)
-
Ohana/src/relphot/src/reload_catalogs.c (modified) (1 diff)
-
Ohana/src/relphot/src/relphot.c (modified) (1 diff)
-
Ohana/src/relphot/src/relphot_client.c (modified) (1 diff)
-
Ohana/src/relphot/src/relphot_images.c (modified) (1 diff)
-
Ohana/src/relphot/src/relphot_parallel_images.c (copied) (copied from trunk/Ohana/src/relphot/src/relphot_parallel_images.c )
-
Ohana/src/relphot/src/relphot_parallel_regions.c (copied) (copied from trunk/Ohana/src/relphot/src/relphot_parallel_regions.c )
-
Ohana/src/relphot/src/select_images.c (modified) (2 diffs)
-
Ohana/src/relphot/src/setMrelCatalog.c (modified) (13 diffs)
-
Ohana/src/relphot/src/share_image_mags.c (copied) (copied from trunk/Ohana/src/relphot/src/share_image_mags.c )
-
Ohana/src/relphot/src/share_mean_mags.c (copied) (copied from trunk/Ohana/src/relphot/src/share_mean_mags.c )
-
Ohana/src/relphot/src/syncfile.c (copied) (copied from trunk/Ohana/src/relphot/src/syncfile.c )
-
Ohana/src/tools/src/medianfilter.c (modified) (2 diffs)
-
Ohana/src/uniphot/src/find_image_sgroups.c (modified) (1 diff)
-
Ohana/src/uniphot/src/update_dvo_setphot.c (modified) (1 diff)
-
Ohana/src/uniphot/src/update_dvo_uniphot.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ps2-tc3-20130727
- Property svn:mergeinfo changed
-
branches/eam_branches/ps2-tc3-20130727/Ohana
- Property svn:mergeinfo deleted
-
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/GetFileMode.c
r35416 r36680 12 12 gfits_scan_alt (header, "SIMPLE", "%t", 1, &simple); 13 13 int haveNaxis = gfits_scan (header, "NAXIS", "%d", 1, &Naxis); 14 int haveCTYPE = gfits_scan (header, "CTYPE 1", "%s", 1, ctype);14 int haveCTYPE = gfits_scan (header, "CTYPE2", "%s", 1, ctype); 15 15 16 16 gfits_scan_alt (header, "EXTEND", "%t", 1, &extend); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/LoadDataPMM.c
r34088 r36680 193 193 194 194 // XXX for now, we define a totally fake coordinate system centered on the plate center 195 strcpy (image[0].coords.ctype, " RA---TAN");195 strcpy (image[0].coords.ctype, "DEC--TAN"); 196 196 197 197 image[0].coords.crval1 = pmm_get_ra (RA); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/ReadStarsSDSS.c
r34088 r36680 201 201 202 202 // XXX for now, we define a totally fake coordinate system centered on the first listed star 203 strcpy (images[N].coords.ctype, " RA---TAN");203 strcpy (images[N].coords.ctype, "DEC--TAN"); 204 204 205 205 images[N].coords.crval1 = stars[0].average.R; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/fakeimage.c
r30613 r36680 34 34 35 35 /* create a mosaic distortion structure */ 36 strcpy (MOSAIC.ctype, " RA---DIS");36 strcpy (MOSAIC.ctype, "DEC--DIS"); 37 37 MOSAIC.crval1 = FAKE_RA; 38 38 MOSAIC.crval2 = FAKE_DEC; … … 86 86 strcpy (image[i+1].name, name); 87 87 88 strcpy (image[i+1].coords.ctype, " RA---WRP");88 strcpy (image[i+1].coords.ctype, "DEC--WRP"); 89 89 90 90 image[i+1].coords.crval1 = dX*pixscale; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/find_matches.c
r34361 r36680 65 65 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 66 66 tcoords.Npolyterms = 1; 67 strcpy (tcoords.ctype, " RA---ARC");67 strcpy (tcoords.ctype, "DEC--ARC"); 68 68 69 69 /* build spatial index (RA sort) referencing input array sequence */ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/find_matches_closest.c
r34361 r36680 64 64 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 65 65 tcoords.Npolyterms = 1; 66 strcpy (tcoords.ctype, " RA---ARC");66 strcpy (tcoords.ctype, "DEC--ARC"); 67 67 68 68 /* build spatial index (RA sort) referencing input array sequence */ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/find_matches_closest_refstars.c
r34361 r36680 59 59 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 60 60 tcoords.Npolyterms = 0; 61 strcpy (tcoords.ctype, " RA---ARC");61 strcpy (tcoords.ctype, "DEC--ARC"); 62 62 63 63 /* build spatial index (RA sort) referencing input array sequence */ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/find_matches_refstars.c
r34260 r36680 57 57 tcoords.pc1_1 = tcoords.pc2_2 = 1.0; 58 58 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 59 strcpy (tcoords.ctype, " RA---ZEA");59 strcpy (tcoords.ctype, "DEC--ZEA"); 60 60 tcoords.Npolyterms = 0; 61 61 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/findskycell.c
r34844 r36680 12 12 // in an even more specific case, RA[i,zone] = RA_origin[zone] + RA_offset[zone] 13 13 14 enum {TREE_NONE, TREE_MAKE, TREE_USE}; 14 enum {TREE_NONE, TREE_MAKE, TREE_LOCAL, TREE_USE}; 15 enum {REGION_NONE, REGION_USER, REGION_MIN, REGION_MAX}; 15 16 16 17 void usage (void) { 17 18 fprintf (stderr, "USAGE: findcell -mktree (tree) (catdir) [-nx Nx] [-ny Ny]\n"); 19 fprintf (stderr, "USAGE: findcell -mklocal (file) (catdir) [-nx Nx] [-ny Ny]\n"); 18 20 fprintf (stderr, "USAGE: findcell -tree (tree) (datafile)\n"); 19 21 fprintf (stderr, " (datafile) should contain a list of RA,DEC pairs\n"); … … 22 24 23 25 int mktree (char *treefile, char *catdir); 26 int mklocal (char *treefile, char *catdir); 24 27 int apply_tree (char *treefile, char *datafile); 25 28 … … 28 31 int NY_SUB = 1; 29 32 33 double R_MIN = 0.0; 34 double R_MAX = 0.0; 35 double D_MIN = 0.0; 36 double D_MAX = 0.0; 37 int REGION_OPTION = REGION_NONE; 38 39 char *BASENAME = NULL; 40 int projectIDoff = -1; 41 int skycellIDoff = -1; 42 43 int APPEND = FALSE; 44 30 45 int main (int argc, char **argv) { 31 46 … … 42 57 if (get_argument (argc, argv, "-h")) usage (); 43 58 44 NX_SUB = NY_SUB = 1;45 59 if ((N = get_argument (argc, argv, "-nx"))) { 46 60 remove_argument (N, &argc, argv); … … 55 69 56 70 /* pixel scale (arcsec/pixel) */ 57 SCALE = 1.0;58 71 if ((N = get_argument (argc, argv, "-scale"))) { 59 72 remove_argument (N, &argc, argv); 60 73 SCALE = atof (argv[N]); 74 remove_argument (N, &argc, argv); 75 } 76 77 /* pixel scale (arcsec/pixel) */ 78 if ((N = get_argument (argc, argv, "-append"))) { 79 remove_argument (N, &argc, argv); 80 APPEND = TRUE; 81 } 82 83 // user-specified region 84 R_MIN = NAN; 85 R_MAX = NAN; 86 D_MIN = NAN; 87 D_MAX = NAN; 88 if ((N = get_argument (argc, argv, "-region"))) { 89 remove_argument (N, &argc, argv); 90 if (N > argc - 4) { 91 fprintf (stderr, "USAGE: -region requires 4 arguments (Rmin Rmax Dmin Dmax)\n"); 92 exit (1); 93 } 94 R_MIN = atof (argv[N]); remove_argument (N, &argc, argv); 95 R_MAX = atof (argv[N]); remove_argument (N, &argc, argv); 96 D_MIN = atof (argv[N]); remove_argument (N, &argc, argv); 97 D_MAX = atof (argv[N]); remove_argument (N, &argc, argv); 98 REGION_OPTION = REGION_USER; 99 } 100 101 if ((N = get_argument (argc, argv, "-region-min"))) { 102 remove_argument (N, &argc, argv); 103 REGION_OPTION = REGION_MIN; 104 } 105 106 if ((N = get_argument (argc, argv, "-region-max"))) { 107 remove_argument (N, &argc, argv); 108 REGION_OPTION = REGION_MAX; 109 } 110 111 if ((N = get_argument (argc, argv, "-basename"))) { 112 remove_argument (N, &argc, argv); 113 if (N > argc - 3) { 114 fprintf (stderr, "USAGE: -basename (name) (proj_offset) (skycell_offset)\n"); 115 exit (1); 116 } 117 BASENAME = strcreate (argv[N]); 118 remove_argument (N, &argc, argv); 119 projectIDoff = atoi(argv[N]); 120 remove_argument (N, &argc, argv); 121 skycellIDoff = atoi(argv[N]); 61 122 remove_argument (N, &argc, argv); 62 123 } … … 70 131 remove_argument (N, &argc, argv); 71 132 } 133 if ((N = get_argument (argc, argv, "-mklocal"))) { 134 MODE = TREE_LOCAL; 135 remove_argument (N, &argc, argv); 136 treefile = strcreate (argv[N]); 137 remove_argument (N, &argc, argv); 138 } 72 139 if ((N = get_argument (argc, argv, "-tree"))) { 73 140 MODE = TREE_USE; … … 83 150 if (MODE == TREE_MAKE) { 84 151 mktree (treefile, argv[1]); 152 exit (0); 153 } 154 155 if (MODE == TREE_LOCAL) { 156 mklocal (treefile, argv[1]); 85 157 exit (0); 86 158 } … … 348 420 MARKTIME("-- test %d pts: %f sec\n", Npts, dtime); 349 421 350 BoundaryTreeSave (treefile, &tree); 422 if (APPEND) { 423 int Ntess = 0; 424 TessellationTable *tess = TessellationTableLoad (treefile, &Ntess); 425 REALLOCATE (tess, TessellationTable, Ntess + 1); 426 TessellationTableInit (&tess[Ntess], 1); 427 tess[Ntess].tree = &tree; 428 tess[Ntess].type = TESS_RINGS; 429 tess[Ntess].Rmin = 0; 430 tess[Ntess].Rmax = 360; 431 tess[Ntess].Dmin = -90; 432 tess[Ntess].Dmax = +90; 433 434 if (BASENAME) { 435 tess[Ntess].Nbasename = strlen(BASENAME); 436 tess[Ntess].basename = strcreate(BASENAME); 437 tess[Ntess].projectIDoff = projectIDoff; 438 tess[Ntess].skycellIDoff = skycellIDoff; 439 } 440 441 // add basename an related here... 442 Ntess ++; 443 TessellationTableSave (treefile, tess, Ntess); 444 } else { 445 BoundaryTreeSave (treefile, &tree); 446 } 351 447 352 448 return TRUE; … … 354 450 355 451 int apply_tree (char *treefile, char *datafile) { 452 453 int Ntess = 0; 454 TessellationTable *tess = TessellationTableLoad (treefile, &Ntess); 455 if (!tess) { 456 fprintf (stderr, "error loading tessellation table file %s\n", treefile); 457 exit (2); 458 } 459 460 FILE *f = fopen (datafile, "r"); 461 if (!f) { 462 fprintf (stderr, "error opening data file %s\n", datafile); 463 exit (3); 464 } 465 466 double ra, dec; 467 int Nvalue = 0; 468 while ((Nvalue = fscanf (f, "%lf %lf", &ra, &dec)) != EOF) { 469 470 int tessID, projID, skycellID; 471 472 if (!TessellationPrimaryCellIDs (tess, Ntess, &tessID, &projID, &skycellID, ra, dec)) { 473 fprintf (stderr, "error finding cell for %f,%f\n", ra, dec); 474 continue; 475 } 476 477 fprintf (stdout, "%10.6f %10.6f : %2d %04d %03d : %s\n", ra, dec, tessID, projID, skycellID, tess[tessID].basename); 478 } 479 480 exit (0); 481 } 482 483 int apply_tree_old (char *treefile, char *datafile) { 356 484 357 485 BoundaryTree *tree = BoundaryTreeLoad (treefile); … … 405 533 } 406 534 535 // a given tess is defined by a catdir (more than one per catdir?) 536 // this function takes a catdir and generates an extension for a tess file for a local tess. 537 538 /* 539 540 LOCAL projections are defined by single projection cells. should I be supplying the info on 541 the cmd line or figure out the bounds from the catdir? 542 543 */ 544 545 int mklocal (char *treefile, char *catdir) { 546 547 int i, j, status; 548 FITS_DB db; 549 Image *image; 550 off_t Nimage; 551 double x, y, ra, dec; 552 553 if (REGION_OPTION == REGION_NONE) { 554 fprintf (stderr, "ERROR: need to define bounding region (-region Rmin Rmax Dmin Dmax | -region-min | -region-max)\n"); 555 exit (2); 556 } 557 558 if (!BASENAME) { 559 fprintf (stderr, "ERROR: need to define BASENAME -basename (name) (proj_offset) (skycell_offset)\n"); 560 exit (2); 561 } 562 563 char imagefile[DVO_MAX_PATH]; 564 snprintf (imagefile, DVO_MAX_PATH, "%s/Images.dat", catdir); 565 566 status = dvo_image_lock (&db, imagefile, 2.0, LCK_XCLD); 567 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename); 568 569 /* load or create the image table */ 570 if (db.dbstate == LCK_EMPTY) Shutdown ("can't read image catalog %s", db.filename); 571 572 if (!dvo_image_load (&db, TRUE, FALSE)) Shutdown ("can't read image catalog %s", db.filename); 573 574 // convert database table to internal structure (binary to Image) 575 // 'image' points to the same memory as db->ftable->buffer 576 image = gfits_table_get_Image (&db.ftable, &Nimage, &db.swapped); 577 if (!image) { 578 fprintf (stderr, "ERROR: failed to read images\n"); 579 exit (2); 580 } 581 582 // generate an empty BoundaryTree 583 TessellationTable *tess = NULL; 584 585 int NtessDisk = 0; 586 if (APPEND) { 587 tess = TessellationTableLoad (treefile, &NtessDisk); 588 REALLOCATE (tess, TessellationTable, Nimage + NtessDisk); 589 } else { 590 ALLOCATE (tess, TessellationTable, Nimage + NtessDisk); 591 } 592 593 TessellationTableInit (&tess[NtessDisk], Nimage); 594 595 // find the RA,DEC of the image centers & assign to cells 596 int Ntess = NtessDisk; 597 for (i = 0; i < Nimage; i++) { 598 // user supplied values, do not try to derive from Image.dat 599 tess[Ntess].NX_SUB = NX_SUB; 600 tess[Ntess].NY_SUB = NY_SUB; 601 tess[Ntess].dPix = SCALE/3600.0; 602 603 x = 0.5*image[i].NX; 604 y = 0.5*image[i].NY; 605 XY_to_RD (&ra, &dec, x, y, &image[i].coords); 606 607 tess[Ntess].Ro = ra; 608 tess[Ntess].Do = dec; 609 tess[Ntess].Xo = x; 610 tess[Ntess].Yo = y; 611 tess[Ntess].dX = image[i].NX / NX_SUB; 612 tess[Ntess].dY = image[i].NY / NY_SUB; 613 614 // find the minimum or maximum containing region 615 if ((REGION_OPTION == REGION_MIN) || (REGION_OPTION == REGION_MAX)) { 616 // XXX short cut for now : if the projection cell bounds the equator or 0,360 boundary, this will fail: 617 double R[4], D[4]; 618 XY_to_RD (&R[0], &D[0], 0, 0, &image[i].coords); 619 XY_to_RD (&R[1], &D[1], image[i].NX, 0, &image[i].coords); 620 XY_to_RD (&R[2], &D[2], 0, image[i].NY, &image[i].coords); 621 XY_to_RD (&R[3], &D[3], image[i].NX, image[i].NY, &image[i].coords); 622 623 if (REGION_OPTION == REGION_MIN) { 624 for (j = 0; j < 4; j++) { 625 R_MIN = (R[j] < ra) ? (isfinite(R_MIN) ? MAX(R_MIN, R[j]) : R[j]) : R_MIN; 626 R_MAX = (R[j] > ra) ? (isfinite(R_MAX) ? MIN(R_MAX, R[j]) : R[j]) : R_MAX; 627 D_MIN = (D[j] < dec) ? (isfinite(D_MIN) ? MAX(D_MIN, D[j]) : D[j]) : D_MIN; 628 D_MAX = (D[j] > dec) ? (isfinite(D_MAX) ? MIN(D_MAX, D[j]) : D[j]) : D_MAX; 629 } 630 } else { 631 for (j = 0; j < 4; j++) { 632 R_MIN = (R[j] < ra) ? (isfinite(R_MIN) ? MIN(R_MIN, R[j]) : R[j]) : R_MIN; 633 R_MAX = (R[j] > ra) ? (isfinite(R_MAX) ? MAX(R_MAX, R[j]) : R[j]) : R_MAX; 634 D_MIN = (D[j] < dec) ? (isfinite(D_MIN) ? MIN(D_MIN, D[j]) : D[j]) : D_MIN; 635 D_MAX = (D[j] > dec) ? (isfinite(D_MAX) ? MAX(D_MAX, D[j]) : D[j]) : D_MAX; 636 } 637 } 638 } 639 tess[Ntess].Rmin = R_MIN; 640 tess[Ntess].Rmax = R_MAX; 641 tess[Ntess].Dmin = D_MIN; 642 tess[Ntess].Dmax = D_MAX; 643 644 tess[Ntess].type = TESS_LOCAL; 645 646 // XXX I don't really want to do the work of discovering the rule... 647 tess[Ntess].Nbasename = strlen(BASENAME); 648 tess[Ntess].basename = strcreate(BASENAME); 649 650 tess[Ntess].projectIDoff = projectIDoff; 651 tess[Ntess].skycellIDoff = skycellIDoff; 652 653 Ntess ++; 654 } 655 656 TessellationTableSave (treefile, tess, Ntess); 657 658 return TRUE; 659 } 660 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/loadsupercos_plates.c
r33653 r36680 118 118 119 119 // for now, we define a fake coordinate system based on the boresite center 120 strcpy (image[Nimage].coords.ctype, " RA---TAN");120 strcpy (image[Nimage].coords.ctype, "DEC--TAN"); 121 121 122 122 image[Nimage].coords.crval1 = RAo; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/addstar/src/sky_tessalation.c
r34844 r36680 1106 1106 refcoords[0].Npolyterms = 0; 1107 1107 memset (refcoords[0].polyterms, 0, 14*sizeof(float)); 1108 strcpy (refcoords[0].ctype, " RA---TAN");1108 strcpy (refcoords[0].ctype, "DEC--TAN"); 1109 1109 return (TRUE); 1110 1110 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge
- Property svn:mergeinfo deleted
-
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c
r34277 r36680 167 167 off_t i, oldID, newID; 168 168 169 if (!IDmap->old) { 170 fprintf (stderr, "input database has image IDs, but no Image table\n"); 171 return FALSE; 172 } 173 174 off_t lastID = IDmap->old[IDmap->Nmap-1]; 175 169 176 for (i = 0; i < catalog[0].Nmeasure; i++) { 170 177 oldID = catalog[0].measure[i].imageID; 171 178 if (oldID == 0) continue; 172 179 173 if (!IDmap->old) {174 fprintf (stderr, "input database has image IDs, but no Image table\n");175 }176 177 180 newID = dvo_map_image_ID (IDmap, oldID); 178 181 if (newID == 0) { 182 if (oldID > lastID) { 183 fprintf (stderr, "problem with image IDs : input out of range\n"); 184 fprintf (stderr, "old ID: "OFF_T_FMT", last ID: "OFF_T_FMT"\n", oldID, lastID); 185 exit (2); 186 } 179 187 if (!IDmap->notFound[oldID]) { 180 188 fprintf (stderr, "cannot find image ID "OFF_T_FMT"\n", oldID); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvomergeUpdate.c
r35765 r36680 111 111 SetPhotcodeTable(NULL); 112 112 113 dvomergeUpdate_catalogs (input, output, outsky, inlist, NsecfiltInput, NsecfiltOutput, &IDmap, secfiltMap);113 int status = dvomergeUpdate_catalogs (input, output, outsky, inlist, NsecfiltInput, NsecfiltOutput, &IDmap, secfiltMap); 114 114 115 115 // save the output sky table copy … … 123 123 gettimeofday (&stop, NULL); 124 124 dtime = DTIME (stop, start); 125 126 if (!status) { 127 fprintf (stderr, "ERROR: elapsed time %9.4f sec\n", dtime); 128 exit (3); 129 } 130 125 131 fprintf (stderr, "SUCCESS: elapsed time %9.4f sec\n", dtime); 126 127 132 exit (0); 128 133 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c
r35765 r36680 140 140 } 141 141 142 dvo_update_image_IDs (IDmap, &incatalog); 143 142 144 // merge input into the appropriate output tables 143 145 for (j = 0; j < outlist[0].Nregions; j++) { … … 156 158 LoadCatalog (&outcatalog, outlist[0].regions[j], outcatalog.filename, "w", NsecfiltOutput); 157 159 158 dvo_update_image_IDs (IDmap, &incatalog);159 160 merge_catalogs_old (outlist[0].regions[j], &outcatalog, &incatalog, RADIUS, secfiltMap); 160 161 161 162 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF; 162 163 163 if (outstat[ i].missed) {164 if (outstat[j].missed) { 164 165 dmhObjectAdd (outstat[j].history, &outcatalog.header, inStats); 165 166 } … … 248 249 if (FORCE_MERGE) { snprintf (tmpline, DVO_MAX_PATH, "%s -force-merge", command); strcpy (command, tmpline); } 249 250 251 // add some config variables: 252 snprintf (tmpline, DVO_MAX_PATH, "%s -D CATMODE %s", command, CATMODE); strcpy (command, tmpline); 253 snprintf (tmpline, DVO_MAX_PATH, "%s -D CATFORMAT %s", command, CATFORMAT); strcpy (command, tmpline); 254 snprintf (tmpline, DVO_MAX_PATH, "%s -D SKY_DEPTH %d", command, SKY_DEPTH); strcpy (command, tmpline); 255 250 256 fprintf (stderr, "command: %s\n", command); 251 257 … … 275 281 } 276 282 if (!PARALLEL_MANUAL && !PARALLEL_SERIAL) { 277 HostTableWaitJobsGetIO (table, __FILE__, __LINE__, VERBOSE); 283 int status = HostTableWaitJobsGetIO (table, __FILE__, __LINE__, VERBOSE); 284 if (!status) { 285 fprintf (stderr, "error running one of the remote clients\n"); 286 return status; 287 } 278 288 } 279 289 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvoverify_args.c
r34405 r36680 56 56 } 57 57 58 /*** dvoverify -parallel (dvoverify_client, actually) ignores this argument 59 dvoverify should save a subset table of just the IDs, and dvoverify_client should load it 60 dvoverify -cpt should have CHECK_IMAGE_ID = F as default ***/ 61 58 62 CHECK_IMAGE_ID = TRUE; 59 63 if ((N = get_argument (*argc, argv, "-skip-image-ids"))) { -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvoverify_catalogs.c
r34405 r36680 143 143 continue; 144 144 } 145 fscanf (results, "%*s %d %*s %d", &NbadHost, &NNotSortedHost); 145 int Nresults = fscanf (results, "%*s %d %*s %d", &NbadHost, &NNotSortedHost); 146 if (Nresults != 2) { 147 fprintf (stderr, "warning: failure scanning results\n"); 148 fclose (results); 149 continue; 150 } 146 151 *Nbad += NbadHost; 147 152 NNotSorted += NNotSortedHost; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvoverify_utils.c
r35457 r36680 302 302 for (j = 0; j < catalog[0].average[i].Nmeasure; j++) { 303 303 id = catalog[0].measure[m+j].imageID; 304 if (id == 0) continue; // detections from ref photcodes can (should) have unset image IDs 304 305 if (id > maxID) { 305 306 Nfail ++; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/merge_catalogs_old.c
r35416 r36680 76 76 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 77 77 tcoords.Npolyterms = 1; 78 strcpy (tcoords.ctype, " RA---ARC");78 strcpy (tcoords.ctype, "DEC--ARC"); 79 79 80 80 if (VERBOSE) fprintf (stderr, "merging %s into %s\n", input[0].filename, output[0].filename); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvopsps/include/dvopsps.h
r35578 r36680 3 3 # include <signal.h> 4 4 # include "mysql.h" 5 # include "limits.h" 5 6 6 7 # define DVO_MAX_PATH 1024 … … 38 39 int PARALLEL_MANUAL; 39 40 int PARALLEL_SERIAL; 41 42 char *TIME_START; 43 char *TIME_END; 44 45 int PHOTCODE_START; 46 int PHOTCODE_END; 40 47 41 48 char *SINGLE_CPT; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvopsps/src/initialize_dvopsps.c
r35206 r36680 2 2 3 3 void usage_dvopsps () { 4 fprintf (stderr, "USAGE: dvopsps (mode) [dbinfo] (mode)[options]\n");4 fprintf (stderr, "USAGE: dvopsps (mode) [dbinfo] [options]\n"); 5 5 fprintf (stderr, " mysql database info is supplied with these:\n"); 6 6 fprintf (stderr, " -dbhost : database host machine\n"); … … 11 11 fprintf (stderr, " -v : verbose mode\n"); 12 12 fprintf (stderr, " -region Rmin Rmax Dmin Dmax\n"); 13 fprintf (stderr, " -cpt n0000/0000.00 : limit to the named cpt file\n"); 13 14 fprintf (stderr, " -parallel : run in parallel mode\n"); 15 fprintf (stderr, " -insert-remote : in parallel mode, the client sends the data to the dbhost\n"); 16 fprintf (stderr, " -time-start YYYY/MM/DD,hh:mm:ss : limit detections to >= this time\n"); 17 fprintf (stderr, " -time-end YYYY/MM/DD,hh:mm:ss : limit detections to < this time\n"); 18 19 fprintf (stderr, " -photcode-start NN : limit detections to >= this photcode number\n"); 20 fprintf (stderr, " -photcode-end NN : limit detections to < this photcode number\n"); 21 fprintf (stderr, "\n"); 22 23 fprintf (stderr, " (mode) is one of detections, objects, skytable\n"); 24 25 fprintf (stderr, "\n"); 14 26 fprintf (stderr, " -h : this help list\n"); 15 27 fprintf (stderr, " -help : this help list\n"); 16 28 fprintf (stderr, " --h : this help list\n"); 17 29 fprintf (stderr, " --help : this help list\n"); 30 18 31 fprintf (stderr, " Note that the dvo db can be specified by -D CATDIR (directory)\n"); 19 32 exit (2); … … 110 123 if ((N = get_argument (argc, argv, "-insert-remote"))) { 111 124 SAVE_REMOTE = FALSE; 125 remove_argument (N, &argc, argv); 126 } 127 128 TIME_START = NULL; 129 if ((N = get_argument (argc, argv, "-time-start"))) { 130 remove_argument (N, &argc, argv); 131 TIME_START = strcreate(argv[N]); 132 remove_argument (N, &argc, argv); 133 time_t TIME_START_SEC; 134 if (!ohana_str_to_time (TIME_START, &TIME_START_SEC)) { 135 fprintf (stderr, "error with starting time given by -time-start: %s\n", TIME_START); 136 exit (2); 137 } 138 } 139 140 TIME_END = NULL; 141 if ((N = get_argument (argc, argv, "-time-end"))) { 142 remove_argument (N, &argc, argv); 143 TIME_END = strcreate(argv[N]); 144 remove_argument (N, &argc, argv); 145 time_t TIME_END_SEC; 146 if (!ohana_str_to_time (TIME_END, &TIME_END_SEC)) { 147 fprintf (stderr, "error with starting time given by -time-end: %s\n", TIME_END); 148 exit (2); 149 } 150 } 151 152 PHOTCODE_START = 0; 153 if ((N = get_argument (argc, argv, "-photcode-start"))) { 154 remove_argument (N, &argc, argv); 155 PHOTCODE_START = atoi(argv[N]); 156 remove_argument (N, &argc, argv); 157 } 158 159 PHOTCODE_END = INT_MAX; 160 if ((N = get_argument (argc, argv, "-photcode-end"))) { 161 remove_argument (N, &argc, argv); 162 PHOTCODE_END = atoi(argv[N]); 112 163 remove_argument (N, &argc, argv); 113 164 } … … 260 311 } 261 312 313 TIME_START = NULL; 314 if ((N = get_argument (argc, argv, "-time-start"))) { 315 remove_argument (N, &argc, argv); 316 TIME_START = strcreate(argv[N]); 317 remove_argument (N, &argc, argv); 318 time_t TIME_START_SEC; 319 if (!ohana_str_to_time (TIME_START, &TIME_START_SEC)) { 320 fprintf (stderr, "error with starting time given by -time-start: %s\n", TIME_START); 321 exit (2); 322 } 323 } 324 325 TIME_END = NULL; 326 if ((N = get_argument (argc, argv, "-time-end"))) { 327 remove_argument (N, &argc, argv); 328 TIME_END = strcreate(argv[N]); 329 remove_argument (N, &argc, argv); 330 time_t TIME_END_SEC; 331 if (!ohana_str_to_time (TIME_END, &TIME_END_SEC)) { 332 fprintf (stderr, "error with starting time given by -time-end: %s\n", TIME_END); 333 exit (2); 334 } 335 } 336 337 PHOTCODE_START = 0; 338 if ((N = get_argument (argc, argv, "-photcode-start"))) { 339 remove_argument (N, &argc, argv); 340 PHOTCODE_START = atoi(argv[N]); 341 remove_argument (N, &argc, argv); 342 } 343 344 PHOTCODE_END = INT_MAX; 345 if ((N = get_argument (argc, argv, "-photcode-end"))) { 346 remove_argument (N, &argc, argv); 347 PHOTCODE_END = atoi(argv[N]); 348 remove_argument (N, &argc, argv); 349 } 350 262 351 VERBOSE = FALSE; 263 352 if ((N = get_argument (argc, argv, "-v"))) { -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvopsps/src/insert_detections_dvopsps.c
r35804 r36680 152 152 if (VERBOSE) { snprintf (tmpline, 1024, "%s -v", command); strcpy (command, tmpline); } 153 153 if (SAVE_REMOTE) { snprintf (tmpline, 1024, "%s -save %s", command, table->hosts[i].results); strcpy (command, tmpline); } 154 155 // some filters -- these are the detections we skip 156 if (TIME_START) { snprintf (tmpline, 1024, "%s -time-start %s", command, TIME_START); strcpy (command, tmpline); } 157 if (TIME_END) { snprintf (tmpline, 1024, "%s -time-end %s", command, TIME_END); strcpy (command, tmpline); } 158 159 if (PHOTCODE_START > 0) { snprintf (tmpline, 1024, "%s -photcode-start %d", command, PHOTCODE_START); strcpy (command, tmpline); } 160 if (PHOTCODE_END <= INT_MAX) { snprintf (tmpline, 1024, "%s -photcode-end %d", command, PHOTCODE_END); strcpy (command, tmpline); } 154 161 155 162 fprintf (stderr, "command: %s\n", command); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvopsps/src/insert_detections_dvopsps_catalog.c
r35777 r36680 29 29 } 30 30 31 time_t TIME_START_SEC = 0; 32 time_t TIME_END_SEC = 0; 33 if (TIME_START) ohana_str_to_time (TIME_START, &TIME_START_SEC); // we validate this in the args.c 34 if (TIME_END) ohana_str_to_time (TIME_END, &TIME_END_SEC); // we validate this in the args.c 35 31 36 for (i = 0; i < catalog[0].Naverage; i++) { 32 37 … … 40 45 Average *average = &catalog->average[i]; 41 46 Measure *measure = &catalog->measure[m + j]; 47 48 // some filters -- these are the detections we skip 49 if (TIME_START && (measure->t < TIME_START_SEC)) continue; 50 if (TIME_END && (measure->t >= TIME_END_SEC)) continue; 51 52 if (measure->photcode < PHOTCODE_START) continue; 53 if (measure->photcode >= PHOTCODE_END) continue; 54 42 55 PhotCode *code = GetPhotcodebyCode(measure->photcode); 43 56 … … 87 100 } 88 101 102 time_t TIME_START_SEC = 0; 103 time_t TIME_END_SEC = INT_MAX; 104 89 105 int insert_detections_dvopsps_catalog (Catalog *catalog, MYSQL *mysql) { 90 106 … … 108 124 int status = TRUE; 109 125 126 if (TIME_START) ohana_str_to_time (TIME_START, &TIME_START_SEC); // we validate this in the args.c 127 if (TIME_END) ohana_str_to_time (TIME_END, &TIME_END_SEC); // we validate this in the args.c 128 110 129 // NOTE for testing, just do a few objects 111 130 if (!mysql) { … … 121 140 for (j = 0; j < average[i].Nmeasure; j++) { 122 141 142 off_t Nmeas = m + j; 143 144 // some filters -- these are the detections we skip (not an error, just skipped) 145 if (TIME_START && (measure[Nmeas].t < TIME_START_SEC)) continue; 146 if (TIME_END && (measure[Nmeas].t >= TIME_END_SEC)) continue; 147 148 if (measure[Nmeas].photcode < PHOTCODE_START) continue; 149 if (measure[Nmeas].photcode >= PHOTCODE_END) continue; 150 123 151 // XXX check return status 124 if (!insert_detections_mysql_value (&buffer, &average[i], &measure[ m+j])) {152 if (!insert_detections_mysql_value (&buffer, &average[i], &measure[Nmeas])) { 125 153 fprintf (stderr, "failure to insert detections in mysql\n"); 126 154 status = FALSE; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/fixcat/src/gcatstats.c
r27435 r36680 52 52 catstats[0].coords.pc1_1 = catstats[0].coords.pc2_2 = 1.0; 53 53 catstats[0].coords.pc1_2 = catstats[0].coords.pc2_1 = 0.0; 54 strcpy (catstats[0].coords.ctype, " RA---TAN");54 strcpy (catstats[0].coords.ctype, "DEC--TAN"); 55 55 56 56 X1 = catstats[0].X; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/gastro/src/gstars.c
r34088 r36680 79 79 if (!strcasecmp (ROUGH_ASTROMETRY, "config")) { 80 80 /* default values for coords */ 81 strcpy (coords[0].ctype, " RA---TAN");81 strcpy (coords[0].ctype, "DEC--TAN"); 82 82 coords[0].pc1_1 = CCD_PC1_1; coords[0].pc1_2 = CCD_PC1_2; 83 83 coords[0].pc2_1 = CCD_PC2_1; coords[0].pc2_2 = CCD_PC2_2; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/gastro2/src/coordtest.c
r8300 r36680 85 85 fit_eval (); 86 86 87 strcpy (coords.ctype, " RA---PLY");87 strcpy (coords.ctype, "DEC--PLY"); 88 88 coords.crval1 = 0.0; 89 89 coords.crval2 = 0.0; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/gastro2/src/gstars2.c
r34088 r36680 28 28 29 29 /* default values for coords */ 30 strcpy (Target[0].coords.ctype, " RA---TAN");30 strcpy (Target[0].coords.ctype, "DEC--TAN"); 31 31 Target[0].coords.pc1_1 = CCD_PC1_1; Target[0].coords.pc1_2 = CCD_PC1_2; 32 32 Target[0].coords.pc2_1 = CCD_PC2_1; Target[0].coords.pc2_2 = CCD_PC2_2; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/getstar/src/GetFileMode.c
r34088 r36680 10 10 gfits_scan_alt (header, "SIMPLE", "%t", 1, &simple); 11 11 haveNaxis = gfits_scan (header, "NAXIS", "%d", 1, &Naxis); 12 haveCTYPE = gfits_scan (header, "CTYPE 1", "%s", 1, ctype);12 haveCTYPE = gfits_scan (header, "CTYPE2", "%s", 1, ctype); 13 13 14 14 gfits_scan_alt (header, "EXTEND", "%t", 1, &extend); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/getstar/src/MatchImages.c
r34430 r36680 36 36 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 37 37 tcoords.Npolyterms = 1; 38 strcpy (tcoords.ctype, " RA---TAN");38 strcpy (tcoords.ctype, "DEC--TAN"); 39 39 /* register so image->sky conversions below have correct mosaic */ 40 40 } else { … … 44 44 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 45 45 tcoords.Npolyterms = 1; 46 strcpy (tcoords.ctype, " RA---TAN");46 strcpy (tcoords.ctype, "DEC--TAN"); 47 47 } 48 48 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/getstar/src/dvoImagesAtCoords.c
r33658 r36680 9 9 static int makePoint(double ra, double dec, Point **pointsOut); 10 10 static int ListImagesAtCoords (Image *dbImages, Point *points, int Npoints); 11 static int readPointFromFile(FILE *f, Point *pt); 11 12 12 13 int main (int argc, char **argv) { … … 15 16 int status; 16 17 Image *dbImages; 17 int Npoints;18 18 FITS_DB db; 19 19 … … 22 22 args_coords (argc, argv); 23 23 24 Point *points; 24 Point *points = NULL; 25 int readStdin = 0; 26 int Npoints = 0; 25 27 if (coordsFile) { 26 Npoints = readPoints(coordsFile, &points); 28 if (strcmp(coordsFile, "-") == 0) { 29 readStdin = 1; 30 } else { 31 Npoints = readPoints(coordsFile, &points); 32 } 27 33 } else { 28 34 Npoints = makePoint(cmd_line_ra, cmd_line_dec, &points); 29 35 } 30 if (!Npoints ) {36 if (!Npoints && !readStdin) { 31 37 exit(1); 32 38 } … … 61 67 } 62 68 63 if (MatchCoords (dbImages, NdbImages, points, Npoints)) { 64 ListImagesAtCoords(dbImages, points, Npoints); 65 exit(0); 69 if (readStdin) { 70 Point pt; 71 memset(&pt, 0, sizeof(pt)); 72 pt.Nmatches = 0; 73 ALLOCATE(pt.matches, Match, 20); 74 pt.arrayLength = 20; 75 76 int status; 77 while ((status = readPointFromFile(stdin, &pt))) { 78 if (status < 0) { 79 fprintf(stdout, "ERROR malformed input line\n"); 80 exit(1); 81 } 82 if (MatchCoords (dbImages, NdbImages, &pt, 1)) { 83 ListImagesAtCoords(dbImages, &pt, 1); 84 } 85 fprintf(stdout, "DONE\n"); 86 fflush(stdout); 87 pt.Nmatches = 0; 88 } 66 89 } else { 67 exit(PSTAMP_NO_OVERLAP); 68 } 90 if (MatchCoords (dbImages, NdbImages, points, Npoints)) { 91 ListImagesAtCoords(dbImages, points, Npoints); 92 } else { 93 exit(PSTAMP_NO_OVERLAP); 94 } 95 } 96 exit(0); 97 } 98 99 static int readPointFromFile(FILE *f, Point *pt) { 100 char buf[80]; 101 char *good = fgets(buf, 80, f); 102 if (!good) { 103 return 0; 104 } 105 // fprintf(stderr, "READ: %s\n", buf); 106 int Nread = sscanf(buf, "%d %lf %lf\n", &pt->id, &pt->ra, &pt->dec); 107 if (Nread == 3) { 108 // got one 109 return 1; 110 } else if (Nread == -1) { 111 // all done time to go 112 return 0; 113 } else { 114 // fprintf(stderr, "malformed input line: %d\n", Nread); 115 return -1; 116 } 69 117 } 70 118 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/kapa2/include/constants.h
r35766 r36680 15 15 // XXX for the moment, this is set to match the values in SetColorScale3D_CC 16 16 # define NPIXELS_STATIC 128 17 // # define NPIXELS_STATIC 100017 // # define NPIXELS_STATIC 4600 -- if we want fullcolor to work, need this 18 18 19 19 # define PAD1 3 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/kapa2/src/Graphs.c
r29539 r36680 64 64 graph[0].data.coords.crpix2 = 0.0; 65 65 graph[0].data.coords.cdelt1 = graph[0].data.coords.cdelt2 = 1.0; 66 strcpy (graph[0].data.coords.ctype, " RA---LIN");66 strcpy (graph[0].data.coords.ctype, "DEC--LIN"); 67 67 strcpy (graph[0].data.axis, "2222"); 68 68 strcpy (graph[0].data.ticks, "2222"); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/kapa2/src/Image.c
r29938 r36680 18 18 channel->coords.crpix2 = 0.0; 19 19 channel->coords.cdelt1 = channel->coords.cdelt2 = 1.0; 20 strcpy (channel->coords.ctype, " RA---LIN");20 strcpy (channel->coords.ctype, "DEC--LIN"); 21 21 channel->coords.Npolyterms = 0; 22 22 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/kapa2/src/bDrawObjects.c
r35416 r36680 315 315 D = scaleSize ? dz*z[i] : ds; 316 316 FillRectangle (buffer, sx, sy, 2*D, 2*D); 317 // plot range saturated by bDrawRectFill 317 318 } 318 319 } … … 335 336 D = scaleSize ? dz*z[i] : ds; 336 337 DrawRectangle (buffer, sx, sy, 2*D, 2*D); 338 // plot range saturated by bDrawRectOpen 337 339 } 338 340 } … … 356 358 DrawLine (buffer, sx - D, sy, sx + D, sy); 357 359 DrawLine (buffer, sx, sy - D, sx, sy + D); 360 // out-of-range points skipped by bDrawPoint 358 361 } 359 362 } … … 377 380 DrawLine (buffer, sx + D, sy - D, sx - D, sy + D); 378 381 DrawLine (buffer, sx - D, sy - D, sx + D, sy + D); 382 // out-of-range points skipped by bDrawPoint 379 383 } 380 384 } … … 398 402 // FillTriangle (buffer, sx - D, sy - 0.58*D, sx + D, sy - 0.58*D, sx, sy + 1.15*D); 399 403 FillTriangle (buffer, sx, sy + 0.58*D, D, -1.73*D); 404 // out-of-range points skipped by bDrawPoint 400 405 } 401 406 } … … 418 423 D = scaleSize ? dz*z[i] : ds; 419 424 OpenTriangle (buffer, sx - D, sy + 0.58*D, sx + D, sy + 0.58*D, sx, sy - 1.15*D); 425 // out-of-range points skipped by bDrawPoint 420 426 } 421 427 } … … 440 446 DrawLine (buffer, sx, sy, sx + D, sy - 0.58*D); 441 447 DrawLine (buffer, sx, sy, sx, sy + 1.15*D); 448 // out-of-range points skipped by bDrawPoint 442 449 } 443 450 } … … 460 467 D = scaleSize ? dz*z[i] : ds; 461 468 DrawCircle (buffer, sx, sy, D); 469 // out-of-range points skipped by bDrawPoint 462 470 } 463 471 } … … 484 492 DrawLine (buffer, sx - 0.58*D, sy + 0.81*D, sx - 0.95*D, sy - 0.31*D); 485 493 DrawLine (buffer, sx - 0.95*D, sy - 0.31*D, sx + 0.00*D, sy - 1.00*D); 494 // out-of-range points skipped by bDrawPoint 486 495 } 487 496 } … … 509 518 DrawLine (buffer, sx + 0.50*D, sy - 0.87*D, sx - 0.50*D, sy - 0.87*D); 510 519 DrawLine (buffer, sx - 0.50*D, sy - 0.87*D, sx - D, sy); 520 // out-of-range points skipped by bDrawPoint 511 521 } 512 522 } … … 529 539 D = scaleSize ? dz*z[i] : ds; 530 540 FillCircle (buffer, sx, sy, D); 541 // out-of-range points skipped by bDrawLineHorizontal 531 542 } 532 543 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/Makefile
r35416 r36680 103 103 $(SRC)/ImageMetadata.$(ARCH).o \ 104 104 $(SRC)/ImageOps.$(ARCH).o \ 105 $(SRC)/RegionHostTable.$(ARCH).o \ 105 106 $(SRC)/match_image.$(ARCH).o \ 106 107 $(SRC)/db_utils.$(ARCH).o \ 107 108 $(SRC)/convert.$(ARCH).o \ 108 109 $(SRC)/HostTable.$(ARCH).o \ 109 $(SRC)/BoundaryTree.$(ARCH).o 110 110 $(SRC)/BoundaryTree.$(ARCH).o \ 111 $(SRC)/TessellationTable.$(ARCH).o 111 112 112 113 # $(SRC)/dvo_convert_panstarrs.$(ARCH).o -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/include/dvo.h
r35755 r36680 285 285 } HostTable; 286 286 287 // A RegionHost processes data for some region in parallel with other regions 288 typedef struct RegionHostInfo { 289 double Rmin; // (Rmin,Rmax),(Dmin,Dmax) arehard RA,DEC boundaries of the 290 double Rmax; // region for which each host is responsible. A given host 291 double Dmin; // calibrates the images for which the fiducial point (center) 292 double Dmax; // lands in the region, and all objects in the region 293 294 double RminCat; // (RminCat,RmaxCat),(DminCat,DmaxCat) are the region for which 295 double RmaxCat; // the catalogs need to be loaded : this is the outer bounds 296 double DminCat; // of the region containing all images completely 297 double DmaxCat; 298 299 char *hostname; 300 301 int hostID; // remove machine ID in SkyTable 302 int stdio[3]; // fd's for communication with the remote host 303 int pid; // remote process ID 304 int status; 305 IOBuffer stdout; 306 IOBuffer stderr; 307 308 off_t Nimage; 309 off_t NIMAGE; 310 Image *image; 311 off_t *imseq; 312 313 int *neighbors; // list of neighbor index values 314 int Nneighbors; // number of neighbors 315 char isNeighbor; // TRUE if I am a neighbor to the current region host 316 } RegionHostInfo; 317 318 typedef struct { 319 double Rmin; 320 double Rmax; 321 double Dmin; 322 double Dmax; 323 324 int Nhosts; 325 RegionHostInfo *hosts; 326 short *index; 327 } RegionHostTable; 328 287 329 // special-case function: 288 330 CMF_PS1_V2 *gfits_table_get_CMF_PS1_V1_Alt (FTable *ftable, off_t *Ndata, char *swapped); … … 308 350 # define BOUNDARY_TREE_NAME_LENGTH 128 309 351 352 // BoundaryTree is a structure to describe the 3pi RINGS skycell boundaries in terms of lines of constant (RA,DEC) 353 // the structure is flexible for a variety of RINGS-like tessellations, but is not appropriate for the LOCAL style tess 310 354 typedef struct { 311 355 int FixedGridDEC; // is the DEC sequence linear? … … 342 386 } BoundaryTree; 343 387 344 // XXX DROP? // a reduced-subset structure for relastro 345 // XXX DROP? typedef struct { 346 // XXX DROP? double R; 347 // XXX DROP? double D; 348 // XXX DROP? unsigned short Nmeasure; 349 // XXX DROP? int measureOffset; 350 // XXX DROP? uint32_t flags; 351 // XXX DROP? int catID; 352 // XXX DROP? } AverageTinyAstro; 388 typedef enum { TESS_NONE, TESS_LOCAL, TESS_RINGS } TessType; 389 390 // TessellationTable is a structure to describe the parameters of a set of "tessellations" 391 // (these are not strictly tessellations but projection sets as only the non-local 392 // versions can cover the full sky). For LOCAL projection cells, the structure describes 393 // the boundaries of a SINGLE projection cell with Nx * Ny skycells and includes some 394 // basic parameters (not used by the fullsky, eg RINGS, tessellations) 395 typedef struct { 396 double Rmin; // this tessellation is valid only for RA >= Rmin 397 double Rmax; // this tessellation is valid only for RA < Rmax 398 double Dmin; // this tessellation is valid only for DEC >= Dmin 399 double Dmax; // this tessellation is valid only for DEC < Dmax 400 401 double Xo; 402 double Yo; 403 double Ro; 404 double Do; 405 double dPix; 406 int dX; 407 int dY; 408 409 int NX_SUB; 410 int NY_SUB; 411 412 char *basename; 413 int Nbasename; 414 int projectIDoff; 415 int skycellIDoff; 416 417 TessType type; // 418 BoundaryTree *tree; 419 } TessellationTable; 353 420 354 421 // a reduced-subset structure for relphot … … 360 427 uint32_t flags; 361 428 int catID; 429 int objID; 430 int nOwn; 362 431 } AverageTiny; 363 432 … … 385 454 short dYccd; 386 455 short dRsys; 456 char myDet; 387 457 } MeasureTiny; 458 459 /** STRUCT DEFINITION **/ 460 typedef struct { 461 double R; // RA (decimal degrees ) 462 double D; // DEC (decimal degrees ) 463 float dR; // RA error (arcsec) 464 float dD; // DEC error (arcsec) 465 float uR; // RA*cos(D) proper-motion (arcsec/year) 466 float uD; // DEC proper-motion (arcsec/year) 467 float duR; // RA*cos(D) p-m error (arcsec/year) 468 float duD; // DEC p-m error (arcsec/year) 469 float P; // parallax (arcsec) 470 float dP; // parallax error (arcsec) 471 float ChiSqAve; // astrometry analysis chisq 472 float ChiSqPM; // astrometry analysis chisq 473 float ChiSqPar; // astrometry analysis chisq 474 int Tmean; // mean epoch (PM,PAR ref) (unix time seconds) 475 int Trange; // mean epoch (PM,PAR ref) (unix time seconds) 476 float Xp; // unused 477 unsigned short Npos; // number of detections used for astrometry 478 unsigned short Nmeasure; // number of psf measurements 479 unsigned short Nmissing; // number of missings 480 unsigned short Nextend; // number of extended measurements 481 uint32_t measureOffset; // offset to first psf measurement 482 uint32_t missingOffset; // offset to first missing obs 483 uint32_t extendOffset; // offset to first extended measurement 484 uint32_t flags; // average object flags (star; ghost; etc) 485 uint32_t photFlagsUpper; // upper bit of 2 bit summary of per-measure photflags 486 uint32_t photFlagsLower; // lower bit of 2 bit summary of per-measure photflags 487 unsigned int objID; // unique ID for object in table 488 unsigned int catID; // unique ID for table in which object was first realized 489 uint64_t extID; // external ID for object (eg PSPS objID) 490 } Average_PS1_V4alt; 491 492 Average_PS1_V4alt *gfits_table_get_Average_PS1_V4alt (FTable *table, off_t *Ndata, char *swapped); 493 Average *Average_PS1_V4alt_ToInternal (Average_PS1_V4alt *in, off_t Nvalues); 494 495 /** STRUCT DEFINITION **/ 496 typedef struct { 497 float dR; // RA offset (arcsec) 498 float dD; // DEC offset (arcsec) 499 float M; // catalog mag (mag) 500 float Mcal; // image cal mag (mag) 501 float Map; // aperture mag (mag) 502 float Mkron; // kron magnitude (mag) 503 float dMkron; // kron magnitude error (mag) 504 float dM; // mag error (mag) 505 float dMcal; // systematic calibration error (mag) 506 float dt; // exposure time (2.5*log(exptime)) 507 float FluxPSF; // flux from psf fit (counts/sec?) 508 float dFluxPSF; // error on psf flux (counts/sec?) 509 float FluxKron; // flux from kron ap (counts/sec?) 510 float dFluxKron; // error on kron flux (counts/sec?) 511 float airmass; // (airmass - 1) (airmass) 512 float az; // telescope azimuth 513 float Xccd; // X coord on chip (raw value) (pixels) 514 float Yccd; // Y coord on chip (raw value) (pixels) 515 float Sky; // local estimate of sky flux (counts/sec) 516 float dSky; // local estimate of sky flux (counts/sec) 517 int t; // time in seconds (UNIX) 518 unsigned int averef; // reference to average entry 519 unsigned int detID; // detection ID 520 unsigned int imageID; // reference to DVO image ID 521 unsigned int objID; // unique ID for object in table 522 unsigned int catID; // unique ID for table in which object was first realized 523 uint64_t extID; // external ID (eg PSPS detID) 524 float psfQF; // psf coverage/quality factor 525 float psfQFperf; // psf coverage / quality factor (all mask bits) 526 float psfChisq; // psf fit chisq 527 int psfNdof; // psf degrees of freedom 528 int psfNpix; // psf number of pixels 529 float crNsigma; // Nsigma deviation towards CR 530 float extNsigma; // Nsigma deviation towards EXT 531 short FWx; // object fwhm major axis (1/100 of pixels) 532 short FWy; // object fwhm minor axis (1/100 of pixels ) 533 short theta; // angle wrt ccd X dir ((0xffff/360) deg) 534 short Mxx; // second moments in pixel coords (1/100 of pixels) 535 short Mxy; // second moments in pixel coords (1/100 of pixels) 536 short Myy; // second moments in pixel coords (1/100 of pixels) 537 unsigned short t_msec; // time fraction of second (milliseconds) 538 unsigned short photcode; // photcode 539 short dXccd; // X coord error on chip (1/100 of pixels) 540 short dYccd; // Y coord error on chip (1/100 of pixels) 541 short dRsys; // systematic error from astrom (1/100 of pixels) 542 short posangle; // position angle sky to chip ((0xffff/360) deg) 543 float pltscale; // plate scale (arcsec/pixel) 544 unsigned int dbFlags; // flags supplied by analysis in database 545 unsigned int photFlags; // flags supplied by photometry program 546 } Measure_PS1_V4alt; 547 548 Measure_PS1_V4alt *gfits_table_get_Measure_PS1_V4alt (FTable *table, off_t *Ndata, char *swapped); 549 Measure *Measure_PS1_V4alt_ToInternal (Measure_PS1_V4alt *in, off_t Nvalues); 388 550 389 551 /* a catalog contains this data */ … … 438 600 float *X; 439 601 float *Y; 602 int *nOwn; // relastro uses this to count owned detections per object 440 603 441 604 } Catalog; … … 499 662 float PhotInst (Measure *measure); 500 663 float PhotCat (Measure *measure); 501 float PhotAper (Measure *measure);502 float PhotKron (Measure *measure);503 664 float PhotSys (Measure *measure, Average *average, SecFilt *secfilt); 504 665 float PhotRel (Measure *measure, Average *average, SecFilt *secfilt); … … 506 667 float PhotAve (PhotCode *code, Average *average, SecFilt *secfilt); 507 668 float PhotRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure); 669 float PhotAveErr (PhotCode *code, Average *average, SecFilt *secfilt); 670 671 float PhotAperInst (Measure *measure); 672 float PhotAperCat (Measure *measure); 673 float PhotAperSys (Measure *measure, Average *average, SecFilt *secfilt); 674 float PhotAperRel (Measure *measure, Average *average, SecFilt *secfilt); 675 float PhotAperCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code); 676 float PhotAperAve (PhotCode *code, Average *average, SecFilt *secfilt); 677 float PhotAperRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure); 678 679 float PhotKronInst (Measure *measure); 680 float PhotKronCat (Measure *measure); 681 float PhotKronSys (Measure *measure, Average *average, SecFilt *secfilt); 682 float PhotKronRel (Measure *measure, Average *average, SecFilt *secfilt); 683 float PhotKronCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code); 684 float PhotKronAve (PhotCode *code, Average *average, SecFilt *secfilt); 685 float PhotKronRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure); 686 float PhotKronAveErr (PhotCode *code, Average *average, SecFilt *secfilt); 687 508 688 float PhotXm (PhotCode *code, Average *average, SecFilt *secfilt); 509 float PhotdM (PhotCode *code, Average *average, SecFilt *secfilt);510 511 float PhotAperInst (Measure *measure);512 float PhotKronInst (Measure *measure);513 float PhotKronAve (PhotCode *code, Average *average, SecFilt *secfilt);514 float PhotKronAveErr (PhotCode *code, Average *average, SecFilt *secfilt);515 689 516 690 float PhotZeroPoint (Measure *measure, Average *average, SecFilt *secfilt); … … 696 870 void sort_coords_index (double *X, double *Y, off_t *S, off_t N); 697 871 void sort_coords_indexonly (double *X, double *Y, off_t *S, off_t N); 872 void sort_IDs_indexonly (opihi_int *X, off_t *S, off_t N); 698 873 void sort_regions (SkyRegion *region, off_t N); 699 874 … … 716 891 int free_tiny_values (Catalog *catalog); 717 892 893 BoundaryTree *BoundaryTreeLoad(char *filename); 894 BoundaryTree *BoundaryTreeRead(Header *headerPHU, Header *headerZone, FILE *f); 895 896 int BoundaryTreeSave(char *filename, BoundaryTree *tree); 897 int BoundaryTreeWrite(FILE *f, BoundaryTree *tree); 898 718 899 int BoundaryTreeCellCoords (BoundaryTree *tree, int *zone, int *band, double ra, double dec); 719 int BoundaryTreeSave(char *filename, BoundaryTree *tree);720 BoundaryTree *BoundaryTreeLoad(char *filename);721 900 int BoundaryTreeProjection (double *x, double *y, double r, double d, BoundaryTree *tree, int zone, int band); 901 902 TessellationTable *TessellationTableLoad(char *filename, int *Ntess); 903 int TessellationTableSave(char *filename, TessellationTable *tess, int Ntess); 904 int TessellationPrimaryCellIDs (TessellationTable *tess, int Ntess, int *tessID, int *projID, int *skycellID, double ra, double dec); 905 void TessellationTableInit (TessellationTable *tess, int Ntess); 722 906 723 907 void dvo_average_init (Average *average); … … 727 911 void dvo_measureT_init (MeasureTiny *measure); 728 912 913 void InitRegionHosts (RegionHostInfo *hosts, int Nhosts, int NHOSTS); 914 void FreeRegionHosts (RegionHostInfo *hosts, int Nhosts); 915 void FreeRegionHostTable (RegionHostTable *table); 916 RegionHostTable *RegionHostTableLoad (char *catdir, char *rootname); 917 int RegionHostTableWaitJobs (RegionHostTable *regionHosts, char *file, int lineno); 918 int RegionHostTableWaitJobsGetIO (RegionHostTable *regionHosts, char *file, int lineno, int VERBOSE); 919 int RegionHostFindNeighbors (RegionHostTable *table, int Nhost); 920 729 921 # endif // DVO_H -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/include/dvodb.h
r35416 r36680 23 23 /* magnitude types */ 24 24 enum {MAG_NONE, 25 MAG_INST, 26 MAG_CAT, 27 MAG_APER, 28 MAG_APER_INST, 29 MAG_KRON, 30 MAG_KRON_INST, 31 MAG_KRON_ERR, 32 MAG_SYS, 33 MAG_REL, 34 MAG_CAL, 25 26 // these magnitude types are from the measurement table (or derived therein) 27 // the following imply PSF magnitudes: 28 MAG_INST, // -2.5*log(DN) [ie, not DN/sec] 29 MAG_CAT, // MAG_INST + 2.5*log(exptime) + C_lambda + K_lambda*(airmass - 1) 30 MAG_SYS, // MAG_CAT + \sum_i A_i * (color_i - color_o) [color correction for measure photcode] 31 MAG_REL, // MAG_SYS - Mcal [specific zero point for image] 32 MAG_CAL, // MAG_REL + \sum_i A_i * (color_i - color_o) [color correction for average photcode] 33 MAG_ERR, // error on PSF MAG 34 35 // the following imply APERTURE magnitudes: 36 MAG_APER_INST, // -2.5*log(DN) [ie, not DN/sec] 37 MAG_APER_CAT, // MAG_APER_INST + 2.5*log(exptime) + C_lambda + K_lambda*(airmass - 1) 38 MAG_APER_SYS, // MAG_APER_CAT + \sum_i A_i * (color_i - color_o) [color correction for measure photcode] 39 MAG_APER_REL, // MAG_APER_SYS - Mcal [specific zero point for image] 40 MAG_APER_CAL, // MAG_APER_REL + \sum_i A_i * (color_i - color_o) [color correction for average photcode] 41 MAG_APER_ERR, // error on APER MAG (if known, else psf error) 42 MAG_APER, // in mextract -> MAG_APER_REL, in avextract -> MAG_APER_AVE 43 44 // the following imply KRON magnitudes: 45 MAG_KRON_INST, // -2.5*log(DN) [ie, not DN/sec] 46 MAG_KRON_CAT, // MAG_KRON_INST + 2.5*log(exptime) + C_lambda + K_lambda*(airmass - 1) 47 MAG_KRON_SYS, // MAG_KRON_CAT + \sum_i A_i * (color_i - color_o) [color correction for measure photcode] 48 MAG_KRON_REL, // MAG_KRON_SYS - Mcal [specific zero point for image] 49 MAG_KRON_CAL, // MAG_KRON_REL + \sum_i A_i * (color_i - color_o) [color correction for average photcode] 50 MAG_KRON_ERR, // error on KRON MAG 51 MAG_KRON, // in mextract -> MAG_KRON_REL, in avextract -> MAG_KRON_AVE 52 53 // these magnitude types are from the average (secfilt) table: 54 // the following imply PSF magnitudes (or fluxes) 35 55 MAG_AVE, 36 56 MAG_REF, 37 MAG_ERR,38 57 MAG_STDEV, 39 58 MAG_AVE_ERR, 59 MAG_CHISQ, 60 MAG_20, 61 MAG_80, 62 MAG_FLUX_PSF, 63 MAG_FLUX_PSF_ERR, 64 65 // the following imply APERTURE magnitudes: 66 MAG_APER_AVE, 67 MAG_APER_REF, 68 69 // the following imply KRON magnitudes or fluxes: 70 MAG_KRON_AVE, 71 MAG_KRON_REF, 72 MAG_FLUX_KRON, 73 MAG_FLUX_KRON_ERR, 74 75 // other secfilt fields of interest 40 76 MAG_PHOT_FLAGS, 41 MAG_CHISQ,42 77 MAG_NCODE, 43 78 MAG_NPHOT, 44 MAG_20,45 MAG_80,46 79 MAG_UC_DIST, 47 80 MAG_STACK_DET_ID, 48 MAG_FLUX_PSF,49 MAG_FLUX_PSF_ERR,50 MAG_FLUX_KRON,51 MAG_FLUX_KRON_ERR,52 81 }; 53 82 … … 174 203 AVE_TMEAN, 175 204 AVE_TRANGE, 205 AVE_PSF_QF, 206 AVE_PSF_QF_PERF, 207 AVE_STARGAL, 176 208 AVE_Xp, 177 209 AVE_NMEAS, … … 372 404 373 405 // Some values used by code moved to libdvo from opihi. 374 enum {OPIHI_ FLT, OPIHI_INT};406 enum {OPIHI_NOTYPE, OPIHI_FLT, OPIHI_INT}; 375 407 #define opihi_flt double 376 408 #define opihi_int int -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/BoundaryTree.c
r35755 r36680 1 1 # include "dvo.h" 2 2 3 # define GET_COLUMN_NEW( OUT,NAME,TYPE)\4 TYPE *OUT = gfits_get_bintable_column_data ( &theader, &ftable, NAME, type, &Nrow, &Ncol); \3 # define GET_COLUMN_NEW(HEADER,FTABLE,OUT,NAME,TYPE) \ 4 TYPE *OUT = gfits_get_bintable_column_data (HEADER, FTABLE, NAME, type, &Nrow, &Ncol); \ 5 5 myAssert (!strcmp(type, #TYPE), "wrong column type"); 6 6 7 # define GET_COLUMN_RAW( OUT,NAME,TYPE)\8 OUT = gfits_get_bintable_column_data ( &theader, &ftable, NAME, type, &Nrow, &Ncol); \7 # define GET_COLUMN_RAW(HEADER,FTABLE,OUT,NAME,TYPE) \ 8 OUT = gfits_get_bintable_column_data (HEADER, FTABLE, NAME, type, &Nrow, &Ncol); \ 9 9 myAssert (!strcmp(type, #TYPE), "wrong column type"); 10 10 … … 12 12 13 13 BoundaryTree *BoundaryTreeLoad(char *filename) { 14 15 Header header; 16 Header theader; 17 Matrix matrix; 18 19 header.buffer = NULL; 20 matrix.buffer = NULL; 21 theader.buffer = NULL; 22 BoundaryTree *tree = NULL; 23 24 FILE *f = fopen (filename, "r"); 25 if (!f) { 26 fprintf (stderr, "ERROR: cannot open boundary tree file %s\n", filename); 27 return NULL; 28 } 29 30 /* load in PHU segment (ignore) */ 31 if (!gfits_fread_header (f, &header)) { 32 if (DEBUG) fprintf (stderr, "can't read boundary tree header\n"); 33 goto escape; 34 } 35 if (!gfits_fread_matrix (f, &matrix, &header)) { 36 if (DEBUG) fprintf (stderr, "can't read boundary tree matrix\n"); 37 goto escape; 38 } 39 40 // load data for this header 41 if (!gfits_load_header (f, &theader)) { 42 if (DEBUG) fprintf (stderr, "can't read boundary tree zone table header\n"); 43 goto escape; 44 } 45 46 tree = BoundaryTreeRead (&header, &theader, f); 47 48 escape: 49 50 gfits_free_header (&theader); 51 gfits_free_header (&header); 52 gfits_free_matrix (&matrix); 53 fclose (f); 54 55 return tree; 56 } 57 58 // assume we are pointing at the relevant table portion 59 BoundaryTree *BoundaryTreeRead(Header *headerPHU, Header *headerZone, FILE *f) { 14 60 15 61 int i, j, nz, nb, Ncol; 16 62 off_t Nrow; 17 63 char type[16]; 18 Header header; 19 Header theader; 20 Matrix matrix; 21 FTable ftable; 22 23 header.buffer = NULL; 24 matrix.buffer = NULL; 25 ftable.buffer = NULL; 26 theader.buffer = NULL; 64 65 FTable ftableZone; 66 67 Header headerCell; 68 FTable ftableCell; 69 70 ftableZone.buffer = NULL; 71 ftableCell.buffer = NULL; 72 headerCell.buffer = NULL; 73 74 // we must have already read in the Zone table header section 75 ftableZone.header = headerZone; 76 ftableCell.header = &headerCell; 77 27 78 BoundaryTree *tree = NULL; 28 79 29 FILE *f = fopen (filename, "r");30 if (!f) {31 fprintf (stderr, "ERROR: cannot open image subset file %s\n", filename);32 return NULL;33 }34 35 /* load in PHU segment (ignore) */36 if (!gfits_fread_header (f, &header)) {37 if (DEBUG) fprintf (stderr, "can't read image subset header\n");38 goto escape;39 }40 if (!gfits_fread_matrix (f, &matrix, &header)) {41 if (DEBUG) fprintf (stderr, "can't read image subset matrix\n");42 goto escape;43 }44 45 80 ALLOCATE (tree, BoundaryTree, 1); 46 81 47 gfits_scan (&header, "DEC_ORI", "%lf", 1, &tree->DEC_origin); 48 gfits_scan (&header, "DEC_OFF", "%lf", 1, &tree->DEC_offset); 49 50 gfits_scan (&header, "NX_SUB", "%d", 1, &tree->NX_SUB); 51 gfits_scan (&header, "NY_SUB", "%d", 1, &tree->NY_SUB); 52 gfits_scan (&header, "PIXSCALE", "%lf", 1, &tree->dPix); 53 54 ftable.header = &theader; 82 // we need to read the boundary tree parameters from the correct header 83 // put them in the PHU header in any case? 84 gfits_scan (headerPHU, "DEC_ORI", "%lf", 1, &tree->DEC_origin); 85 gfits_scan (headerPHU, "DEC_OFF", "%lf", 1, &tree->DEC_offset); 86 gfits_scan (headerPHU, "NX_SUB", "%d", 1, &tree->NX_SUB); 87 gfits_scan (headerPHU, "NY_SUB", "%d", 1, &tree->NY_SUB); 88 gfits_scan (headerPHU, "PIXSCALE", "%lf", 1, &tree->dPix); 55 89 56 90 /*** zone information table ***/ 57 { 58 // load data for this header 59 if (!gfits_load_header (f, &theader)) goto escape; 60 61 // read the fits table bytes 62 if (!gfits_fread_ftable_data (f, &ftable, FALSE)) goto escape; 91 92 // read the fits table bytes 93 if (!gfits_fread_ftable_data (f, &ftableZone, FALSE)) goto escape; 63 94 64 // need to create and assign to flat-field correction 65 GET_COLUMN_RAW(tree->Nband, "NBAND", int); 66 GET_COLUMN_RAW(tree->RA_origin, "RA_ORIGIN", double); 67 GET_COLUMN_RAW(tree->RA_offset, "RA_OFFSET", double); 68 GET_COLUMN_RAW(tree->DEC_min , "DEC_MIN", double); 69 GET_COLUMN_RAW(tree->DEC_max , "DEC_MAX", double); 70 GET_COLUMN_RAW(tree->DEC_min_raw, "DEC_MIN_RAW", double); 71 GET_COLUMN_RAW(tree->DEC_max_raw, "DEC_MAX_RAW", double); 72 gfits_free_header (&theader); 73 gfits_free_table (&ftable); 74 75 fprintf (stderr, "loaded data for %lld zones\n", (long long) Nrow); 76 tree->Nzone = Nrow; 77 78 // allocate the storage arrays 79 ALLOCATE (tree->ra, double *, tree->Nzone); 80 ALLOCATE (tree->dec, double *, tree->Nzone); 81 ALLOCATE (tree->Xo, double *, tree->Nzone); 82 ALLOCATE (tree->Yo, double *, tree->Nzone); 83 ALLOCATE (tree->dX, int *, tree->Nzone); 84 ALLOCATE (tree->dY, int *, tree->Nzone); 85 ALLOCATE (tree->cell, int *, tree->Nzone); 86 ALLOCATE (tree->projID, int *, tree->Nzone); 87 ALLOCATE (tree->name, char **, tree->Nzone); 88 for (i = 0; i < tree->Nzone; i++) { 89 ALLOCATE (tree->ra[i], double, tree->Nband[i]); 90 ALLOCATE (tree->dec[i], double, tree->Nband[i]); 91 ALLOCATE (tree->Xo[i], double, tree->Nband[i]); 92 ALLOCATE (tree->Yo[i], double, tree->Nband[i]); 93 ALLOCATE (tree->dX[i], int, tree->Nband[i]); 94 ALLOCATE (tree->dY[i], int, tree->Nband[i]); 95 ALLOCATE (tree->cell[i], int, tree->Nband[i]); 96 ALLOCATE (tree->projID[i], int, tree->Nband[i]); 97 ALLOCATE (tree->name[i], char *, tree->Nband[i]); 98 for (j = 0; j < tree->Nband[i]; j++) { 99 ALLOCATE (tree->name[i][j], char, BOUNDARY_TREE_NAME_LENGTH); 100 } 95 // need to create and assign to flat-field correction 96 GET_COLUMN_RAW(headerZone, &ftableZone, tree->Nband, "NBAND", int); 97 GET_COLUMN_RAW(headerZone, &ftableZone, tree->RA_origin, "RA_ORIGIN", double); 98 GET_COLUMN_RAW(headerZone, &ftableZone, tree->RA_offset, "RA_OFFSET", double); 99 GET_COLUMN_RAW(headerZone, &ftableZone, tree->DEC_min , "DEC_MIN", double); 100 GET_COLUMN_RAW(headerZone, &ftableZone, tree->DEC_max , "DEC_MAX", double); 101 GET_COLUMN_RAW(headerZone, &ftableZone, tree->DEC_min_raw, "DEC_MIN_RAW", double); 102 GET_COLUMN_RAW(headerZone, &ftableZone, tree->DEC_max_raw, "DEC_MAX_RAW", double); 103 gfits_free_table (&ftableZone); 104 105 fprintf (stderr, "loaded data for %lld zones\n", (long long) Nrow); 106 tree->Nzone = Nrow; 107 108 // allocate the storage arrays 109 ALLOCATE (tree->ra, double *, tree->Nzone); 110 ALLOCATE (tree->dec, double *, tree->Nzone); 111 ALLOCATE (tree->Xo, double *, tree->Nzone); 112 ALLOCATE (tree->Yo, double *, tree->Nzone); 113 ALLOCATE (tree->dX, int *, tree->Nzone); 114 ALLOCATE (tree->dY, int *, tree->Nzone); 115 ALLOCATE (tree->cell, int *, tree->Nzone); 116 ALLOCATE (tree->projID, int *, tree->Nzone); 117 ALLOCATE (tree->name, char **, tree->Nzone); 118 for (i = 0; i < tree->Nzone; i++) { 119 ALLOCATE (tree->ra[i], double, tree->Nband[i]); 120 ALLOCATE (tree->dec[i], double, tree->Nband[i]); 121 ALLOCATE (tree->Xo[i], double, tree->Nband[i]); 122 ALLOCATE (tree->Yo[i], double, tree->Nband[i]); 123 ALLOCATE (tree->dX[i], int, tree->Nband[i]); 124 ALLOCATE (tree->dY[i], int, tree->Nband[i]); 125 ALLOCATE (tree->cell[i], int, tree->Nband[i]); 126 ALLOCATE (tree->projID[i], int, tree->Nband[i]); 127 ALLOCATE (tree->name[i], char *, tree->Nband[i]); 128 for (j = 0; j < tree->Nband[i]; j++) { 129 ALLOCATE (tree->name[i][j], char, BOUNDARY_TREE_NAME_LENGTH); 101 130 } 102 131 } 103 132 104 133 /*** cell information table ***/ 105 { 106 // load data for this header107 if (!gfits_load_header (f, &theader)) goto escape;108 109 // read the fits table bytes110 if (!gfits_fread_ftable_data (f, &ftable, FALSE)) goto escape;134 135 // load data for this header 136 if (!gfits_load_header (f, &headerCell)) goto escape; 137 138 // read the fits table bytes 139 if (!gfits_fread_ftable_data (f, &ftableCell, FALSE)) goto escape; 111 140 112 // need to create and assign to flat-field correction 113 GET_COLUMN_NEW(R, "RA", double); 114 GET_COLUMN_NEW(D, "DEC", double); 115 GET_COLUMN_NEW(zone, "ZONE", int); 116 GET_COLUMN_NEW(band, "BAND", int); 117 GET_COLUMN_NEW(index, "INDEX", int); 118 GET_COLUMN_NEW(Xo, "X_CENT", double); 119 GET_COLUMN_NEW(Yo, "Y_CENT", double); 120 GET_COLUMN_NEW(dX, "X_GRID", int); 121 GET_COLUMN_NEW(dY, "Y_GRID", int); 122 GET_COLUMN_NEW(name, "NAME", char); // XXX how is this done? 123 gfits_free_header (&theader); 124 gfits_free_table (&ftable); 125 fprintf (stderr, "loaded data for %lld cells\n", (long long) Nrow); 126 127 // assign the storage arrays 128 for (i = 0; i < Nrow; i++) { 129 nz = zone[i]; 130 nb = band[i]; 131 tree->ra[nz][nb] = R[i]; 132 tree->dec[nz][nb] = D[i]; 133 tree->Xo[nz][nb] = Xo[i]; 134 tree->Yo[nz][nb] = Yo[i]; 135 tree->dX[nz][nb] = dX[i]; 136 tree->dY[nz][nb] = dY[i]; 137 tree->cell[nz][nb] = i; // XXX ? 138 memcpy(tree->name[nz][nb], &name[i*BOUNDARY_TREE_NAME_LENGTH], BOUNDARY_TREE_NAME_LENGTH); 139 // XXX parse out the ID from the name (skycell.NNNN) 140 tree->projID[nz][nb] = atoi(&tree->name[nz][nb][8]); 141 } 142 143 free (R ); 144 free (D ); 145 free (zone ); 146 free (band ); 147 free (Xo ); 148 free (Yo ); 149 free (dX ); 150 free (dY ); 151 free (index ); 152 free (name ); 153 } 154 155 gfits_free_header (&header); 156 gfits_free_matrix (&matrix); 157 fclose (f); 141 // need to create and assign to flat-field correction 142 GET_COLUMN_NEW(&headerCell, &ftableCell, R, "RA", double); 143 GET_COLUMN_NEW(&headerCell, &ftableCell, D, "DEC", double); 144 GET_COLUMN_NEW(&headerCell, &ftableCell, zone, "ZONE", int); 145 GET_COLUMN_NEW(&headerCell, &ftableCell, band, "BAND", int); 146 GET_COLUMN_NEW(&headerCell, &ftableCell, index, "INDEX", int); 147 GET_COLUMN_NEW(&headerCell, &ftableCell, Xo, "X_CENT", double); 148 GET_COLUMN_NEW(&headerCell, &ftableCell, Yo, "Y_CENT", double); 149 GET_COLUMN_NEW(&headerCell, &ftableCell, dX, "X_GRID", int); 150 GET_COLUMN_NEW(&headerCell, &ftableCell, dY, "Y_GRID", int); 151 GET_COLUMN_NEW(&headerCell, &ftableCell, name, "NAME", char); // XXX how is this done? 152 gfits_free_header (&headerCell); 153 gfits_free_table (&ftableCell); 154 155 fprintf (stderr, "loaded data for %lld cells\n", (long long) Nrow); 156 157 // assign the storage arrays 158 for (i = 0; i < Nrow; i++) { 159 nz = zone[i]; 160 nb = band[i]; 161 tree->ra[nz][nb] = R[i]; 162 tree->dec[nz][nb] = D[i]; 163 tree->Xo[nz][nb] = Xo[i]; 164 tree->Yo[nz][nb] = Yo[i]; 165 tree->dX[nz][nb] = dX[i]; 166 tree->dY[nz][nb] = dY[i]; 167 tree->cell[nz][nb] = i; // XXX ? 168 memcpy(tree->name[nz][nb], &name[i*BOUNDARY_TREE_NAME_LENGTH], BOUNDARY_TREE_NAME_LENGTH); 169 // XXX parse out the ID from the name (skycell.NNNN) 170 tree->projID[nz][nb] = atoi(&tree->name[nz][nb][8]); 171 } 172 173 free (R ); 174 free (D ); 175 free (zone ); 176 free (band ); 177 free (Xo ); 178 free (Yo ); 179 free (dX ); 180 free (dY ); 181 free (index ); 182 free (name ); 158 183 159 184 return tree; 160 185 161 186 escape: 162 gfits_free_header (&header); 163 gfits_free_matrix (&matrix); 164 gfits_free_header (&theader); 165 gfits_free_table (&ftable); 187 gfits_free_header (&headerCell); 188 gfits_free_table (&ftableCell); 189 gfits_free_table (&ftableZone); 166 190 if (tree) free (tree); 167 191 168 fclose (f);169 192 return NULL; 170 193 } … … 173 196 int BoundaryTreeSave(char *filename, BoundaryTree *tree) { 174 197 175 int i, nz, nb;176 198 Header header; 177 Header theader;178 199 Matrix matrix; 179 FTable ftable;180 200 181 201 gfits_init_header (&header); … … 202 222 gfits_free_header (&header); 203 223 gfits_free_matrix (&matrix); 224 225 BoundaryTreeWrite (f, tree); 226 fclose (f); 227 228 return TRUE; 229 } 230 231 int BoundaryTreeWrite(FILE *f, BoundaryTree *tree) { 232 233 int i, nz, nb; 234 Header theader; 235 FTable ftable; 204 236 205 237 /*** zone information table ***/ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/ImageMetadataSelection.c
r35416 r36680 18 18 field.pc1_2 = field.pc2_1 = 0.0; 19 19 field.Npolyterms = 0; 20 strcpy (field.ctype, " RA---SIN");20 strcpy (field.ctype, "DEC--SIN"); 21 21 22 22 /* mosaic defines a frame with 0,0 at the mosaic center, and 1 arcsec / pixel */ … … 26 26 mosaic.pc1_2 = mosaic.pc2_1 = 0.0; 27 27 mosaic.Npolyterms = 0; 28 strcpy (mosaic.ctype, " RA---SIN");28 strcpy (mosaic.ctype, "DEC--SIN"); 29 29 30 30 if ((image = ImageMetadataLoad (filename, &Nimage)) == NULL) return (FALSE); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/ImageSelection.c
r35416 r36680 28 28 mosaic.pc1_2 = mosaic.pc2_1 = 0.0; 29 29 mosaic.Npolyterms = 0; 30 strcpy (mosaic.ctype, " RA---SIN");30 strcpy (mosaic.ctype, "DEC--SIN"); 31 31 } 32 32 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/coordops.c
r34088 r36680 1 1 # include <dvo.h> 2 3 /* note that Coords.ctype carries the DEC (ctype2) value */ 2 4 3 5 static Coords mosaic; … … 621 623 622 624 /* modifications to the ctype? */ 625 /* note that Coords.ctype carries the DEC (ctype2) value */ 623 626 OldAIPS = FALSE; 624 627 gfits_modify (header, "CTYPE2", "%s", 1, coords[0].ctype); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dbCheckStack.c
r35755 r36680 7 7 // these would be better done using bit values to test for field? temp? float? 8 8 // 9 10 #define OPIHI_INT 111 9 12 10 int dbCheckStack (dbStack *stack, int Nstack, int table, dbField **inFields, int *inNfields) { -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dbExtractAverages.c
r35416 r36680 151 151 case AVE_TRANGE: 152 152 value.Flt = TimeValue (average[0].Trange, 0, TimeFormat); 153 break; 154 155 case AVE_PSF_QF: 156 value.Flt = average[0].psfQF; 157 break; 158 case AVE_PSF_QF_PERF: 159 value.Flt = average[0].psfQFperf; 160 break; 161 case AVE_STARGAL: 162 value.Flt = average[0].stargal; 153 163 break; 154 164 … … 201 211 } 202 212 } else { 203 value.Flt = Phot dM(field->photcode, average, secfilt);213 value.Flt = PhotAveErr (field->photcode, average, secfilt); 204 214 } 205 215 break; … … 233 243 break; 234 244 245 case MAG_APER: 246 case MAG_APER_AVE: 247 value.Flt = PhotAperAve (field->photcode, average, secfilt); 248 break; 249 250 case MAG_APER_REF: 251 value.Flt = PhotAperRef (field->photcode, average, secfilt, measure); 252 break; 253 235 254 case MAG_KRON: 255 case MAG_KRON_AVE: 236 256 value.Flt = PhotKronAve (field->photcode, average, secfilt); 257 break; 258 259 case MAG_KRON_REF: 260 value.Flt = PhotKronRef (field->photcode, average, secfilt, measure); 237 261 break; 238 262 … … 269 293 break; 270 294 case AVE_dMAG: 271 value.Flt = Phot dM(field->photcode, average, secfilt);295 value.Flt = PhotAveErr (field->photcode, average, secfilt); 272 296 break; 273 297 case AVE_Xm: -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dbExtractMeasures.c
r35508 r36680 123 123 case MAG_REL: 124 124 case MAG_CAL: 125 case MAG_APER: 125 case MAG_ERR: 126 126 127 case MAG_APER_INST: 127 case MAG_KRON: 128 case MAG_APER_CAT: 129 case MAG_APER_SYS: 130 case MAG_APER_REL: 131 case MAG_APER_CAL: 132 case MAG_APER_ERR: 133 128 134 case MAG_KRON_INST: 135 case MAG_KRON_CAT: 136 case MAG_KRON_SYS: 137 case MAG_KRON_REL: 138 case MAG_KRON_CAL: 129 139 case MAG_KRON_ERR: 130 case MAG_ERR: 140 131 141 case MAG_PHOT_FLAGS: 132 142 equiv = myEquiv; … … 137 147 case MAG_AVE: 138 148 case MAG_REF: 149 case MAG_STDEV: 150 case MAG_AVE_ERR: 139 151 case MAG_CHISQ: 140 case MAG_AVE_ERR: 152 case MAG_FLUX_PSF: 153 case MAG_FLUX_PSF_ERR: 154 155 case MAG_APER_AVE: 156 157 case MAG_KRON_AVE: 158 case MAG_FLUX_KRON: 159 case MAG_FLUX_KRON_ERR: 160 161 case MAG_20: 162 case MAG_80: 163 case MAG_UC_DIST: 164 case MAG_STACK_DET_ID: 165 141 166 case MAG_NCODE: 142 167 case MAG_NPHOT: 143 case MAG_FLUX_PSF:144 case MAG_FLUX_PSF_ERR:145 case MAG_FLUX_KRON:146 case MAG_FLUX_KRON_ERR:147 168 equiv = field->photcode; 148 169 goto valid_photcode; … … 178 199 value.Flt = PhotRef (equiv, average, secfilt, measure); 179 200 break; 180 case MAG_APER: 181 value.Flt = PhotAper (measure); 182 break; 201 case MAG_ERR: 202 value.Flt = measure[0].dM; 203 break; 204 case MAG_AVE_ERR: 205 value.Flt = PhotAveErr (equiv, average, secfilt); 206 break; 207 183 208 case MAG_APER_INST: 184 209 value.Flt = PhotAperInst (measure); 185 210 break; 186 case MAG_KRON: 187 value.Flt = PhotKron (measure); 188 break; 211 case MAG_APER_CAT: 212 value.Flt = PhotAperCat (measure); 213 break; 214 case MAG_APER_SYS: 215 value.Flt = PhotAperSys (measure, average, secfilt); 216 break; 217 case MAG_APER: 218 case MAG_APER_REL: 219 value.Flt = PhotAperRel (measure, average, secfilt); 220 break; 221 case MAG_APER_CAL: 222 value.Flt = PhotAperCal (measure, average, secfilt, measure, equiv); 223 break; 224 case MAG_APER_AVE: 225 value.Flt = PhotAperAve (equiv, average, secfilt); 226 break; 227 case MAG_APER_REF: 228 value.Flt = PhotAperRef (equiv, average, secfilt, measure); 229 break; 230 case MAG_APER_ERR: 231 value.Flt = measure[0].dM; 232 break; 233 189 234 case MAG_KRON_INST: 190 235 value.Flt = PhotKronInst (measure); 191 236 break; 237 case MAG_KRON_CAT: 238 value.Flt = PhotKronCat (measure); 239 break; 240 case MAG_KRON_SYS: 241 value.Flt = PhotKronSys (measure, average, secfilt); 242 break; 243 case MAG_KRON: 244 case MAG_KRON_REL: 245 value.Flt = PhotKronRel (measure, average, secfilt); 246 break; 247 case MAG_KRON_CAL: 248 value.Flt = PhotKronCal (measure, average, secfilt, measure, equiv); 249 break; 250 case MAG_KRON_AVE: 251 value.Flt = PhotKronAve (equiv, average, secfilt); 252 break; 253 case MAG_KRON_REF: 254 value.Flt = PhotKronRef (equiv, average, secfilt, measure); 255 break; 192 256 case MAG_KRON_ERR: 193 value.Flt = measure[0].dMkron; 194 break; 195 case MAG_ERR: 196 value.Flt = measure[0].dM; 197 break; 198 case MAG_AVE_ERR: 199 value.Flt = PhotdM (equiv, average, secfilt); 200 break; 257 value.Flt = measure[0].dMkron; 258 break; 259 201 260 case MAG_PHOT_FLAGS: 202 261 if ((field->photcode->type == PHOT_REF) || (field->photcode->type == PHOT_DEP)) { 203 262 value.Int = measure[0].photFlags; 204 } else {205 value.Int = 0;206 263 } 207 264 break; 208 case MAG_CHISQ: 209 value.Flt = PhotXm (equiv, average, secfilt); 210 break; 265 211 266 case MAG_NCODE: 212 if (equiv == NULL) { 213 value.Int = 0; 214 break; 215 } 267 if (equiv == NULL) break; 216 268 Nsec = GetPhotcodeNsec (equiv->code); 217 269 if (Nsec == -1) break; … … 219 271 break; 220 272 case MAG_NPHOT: 221 if (equiv == NULL) { 222 value.Int = 0; 223 break; 224 } 273 if (equiv == NULL) break; 225 274 Nsec = GetPhotcodeNsec (equiv->code); 226 275 if (Nsec == -1) break; 227 276 value.Int = secfilt[Nsec].Nused; 228 277 break; 278 279 case MAG_CHISQ: 280 value.Flt = PhotXm (equiv, average, secfilt); 281 break; 282 case MAG_STDEV: 283 value.Flt = PhotMstdev (equiv, average, secfilt); 284 break; 285 case MAG_20: 286 value.Flt = PhotM20 (equiv, average, secfilt); 287 break; 288 case MAG_80: 289 value.Flt = PhotM80 (equiv, average, secfilt); 290 break; 291 case MAG_UC_DIST: 292 value.Flt = PhotUCdist (equiv, average, secfilt); 293 break; 294 229 295 case MAG_FLUX_PSF: 230 296 value.Flt = PhotAveFluxPSF (field->photcode, average, secfilt); … … 531 597 fieldc = MatchFieldMetadata (measure[0].imageID); 532 598 } else { 533 fprintf (stderr, "non-parallel Xmos broken\n");534 abort();599 // fprintf (stderr, "non-parallel Xmos broken\n"); 600 // abort(); 535 601 // fieldc = MatchField (measure[0].t, measure[0].photcode); 602 fieldc = MatchFieldMetadata (measure[0].imageID); 536 603 } 537 604 if (fieldc == NULL) break; … … 547 614 fieldc = MatchFieldMetadata (measure[0].imageID); 548 615 } else { 549 fprintf (stderr, "non-parallel Xmos broken\n");550 abort();616 // fprintf (stderr, "non-parallel Xmos broken\n"); 617 // abort(); 551 618 // fieldc = MatchField (measure[0].t, measure[0].photcode); 619 fieldc = MatchFieldMetadata (measure[0].imageID); 552 620 } 553 621 if (fieldc == NULL) break; … … 564 632 mosaic = MatchMosaicMetadata (measure[0].imageID); 565 633 } else { 566 fprintf (stderr, "non-parallel Xmos broken\n"); 567 abort(); 568 mosaic = MatchMosaic (measure[0].t, measure[0].photcode); 634 // fprintf (stderr, "non-parallel Xmos broken\n"); 635 // abort(); 636 // mosaic = MatchMosaic (measure[0].t, measure[0].photcode); 637 mosaic = MatchMosaicMetadata (measure[0].imageID); 569 638 } 570 639 if (mosaic == NULL) break; … … 580 649 mosaic = MatchMosaicMetadata (measure[0].imageID); 581 650 } else { 582 fprintf (stderr, "non-parallel Xmos broken\n"); 583 abort(); 584 mosaic = MatchMosaic (measure[0].t, measure[0].photcode); 651 // fprintf (stderr, "non-parallel Xmos broken\n"); 652 // abort(); 653 // mosaic = MatchMosaic (measure[0].t, measure[0].photcode); 654 mosaic = MatchMosaicMetadata (measure[0].imageID); 585 655 } 586 656 if (mosaic == NULL) break; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dbFields.c
r35416 r36680 30 30 int GetMagMode (char *string) { 31 31 32 // these all imply PSF mags: 32 33 if (!strcasecmp (string, "inst")) return (MAG_INST); 33 34 if (!strcasecmp (string, "cat")) return (MAG_CAT); … … 37 38 if (!strcasecmp (string, "ave")) return (MAG_AVE); 38 39 if (!strcasecmp (string, "ref")) return (MAG_REF); 40 if (!strcasecmp (string, "err")) return (MAG_ERR); 41 if (!strcasecmp (string, "aveerr")) return (MAG_AVE_ERR); 42 43 // these are explicit PSF mags: 44 if (!strcasecmp (string, "psf_inst")) return (MAG_INST); 45 if (!strcasecmp (string, "psf_cat")) return (MAG_CAT); 46 if (!strcasecmp (string, "psf_sys")) return (MAG_SYS); 47 if (!strcasecmp (string, "psf_rel")) return (MAG_REL); 48 if (!strcasecmp (string, "psf_cal")) return (MAG_CAL); 49 if (!strcasecmp (string, "psf_ave")) return (MAG_AVE); 50 if (!strcasecmp (string, "psf_ref")) return (MAG_REF); 51 if (!strcasecmp (string, "psf_err")) return (MAG_ERR); 52 if (!strcasecmp (string, "psf_aveerr")) return (MAG_AVE_ERR); 53 54 // these are aper mags: 39 55 if (!strcasecmp (string, "ap")) return (MAG_APER); 40 56 if (!strcasecmp (string, "aper")) return (MAG_APER); 41 57 if (!strcasecmp (string, "aperinst")) return (MAG_APER_INST); 42 58 if (!strcasecmp (string, "aper_inst")) return (MAG_APER_INST); 59 if (!strcasecmp (string, "aper_cat")) return (MAG_APER_CAT); 60 if (!strcasecmp (string, "aper_sys")) return (MAG_APER_SYS); 61 if (!strcasecmp (string, "aper_rel")) return (MAG_APER_REL); 62 if (!strcasecmp (string, "aper_cal")) return (MAG_APER_CAL); 63 if (!strcasecmp (string, "aper_ave")) return (MAG_APER_AVE); 64 if (!strcasecmp (string, "aper_ref")) return (MAG_APER_REF); 65 if (!strcasecmp (string, "aper_err")) return (MAG_APER_ERR); 66 67 // these are kron mags: 43 68 if (!strcasecmp (string, "kron")) return (MAG_KRON); 69 if (!strcasecmp (string, "kron_inst")) return (MAG_KRON_INST); 70 if (!strcasecmp (string, "kron_cat")) return (MAG_KRON_CAT); 71 if (!strcasecmp (string, "kron_sys")) return (MAG_KRON_SYS); 72 if (!strcasecmp (string, "kron_rel")) return (MAG_KRON_REL); 73 if (!strcasecmp (string, "kron_cal")) return (MAG_KRON_CAL); 74 if (!strcasecmp (string, "kron_ave")) return (MAG_KRON_AVE); 75 if (!strcasecmp (string, "kron_ref")) return (MAG_KRON_REF); 76 if (!strcasecmp (string, "kron_err")) return (MAG_KRON_ERR); 44 77 if (!strcasecmp (string, "kroninst")) return (MAG_KRON_INST); 45 if (!strcasecmp (string, "kron_inst")) return (MAG_KRON_INST);46 78 if (!strcasecmp (string, "kronerr")) return (MAG_KRON_ERR); 47 if (!strcasecmp (string, "err")) return (MAG_ERR); 48 if (!strcasecmp (string, "aveerr")) return (MAG_AVE_ERR);79 80 // other fields: 49 81 if (!strcasecmp (string, "photflags")) return (MAG_PHOT_FLAGS); 50 82 if (!strcasecmp (string, "flags")) return (MAG_PHOT_FLAGS); … … 314 346 } 315 347 316 if (!strcasecmp (fieldName, "RA")) ESCAPE (AVE_RA, MAG_NONE, OPIHI_FLT); 317 if (!strcasecmp (fieldName, "DEC")) ESCAPE (AVE_DEC, MAG_NONE, OPIHI_FLT); 318 if (!strcasecmp (fieldName, "GLON")) ESCAPE (AVE_GLON, MAG_NONE, OPIHI_FLT); 319 if (!strcasecmp (fieldName, "GLAT")) ESCAPE (AVE_GLAT, MAG_NONE, OPIHI_FLT); 320 if (!strcasecmp (fieldName, "ELON")) ESCAPE (AVE_ELON, MAG_NONE, OPIHI_FLT); 321 if (!strcasecmp (fieldName, "ELAT")) ESCAPE (AVE_ELAT, MAG_NONE, OPIHI_FLT); 322 if (!strcasecmp (fieldName, "dRA")) ESCAPE (AVE_RA_ERR, MAG_NONE, OPIHI_FLT); 323 if (!strcasecmp (fieldName, "dDEC")) ESCAPE (AVE_DEC_ERR, MAG_NONE, OPIHI_FLT); 324 if (!strcasecmp (fieldName, "uRA")) ESCAPE (AVE_U_RA, MAG_NONE, OPIHI_FLT); 325 if (!strcasecmp (fieldName, "uDEC")) ESCAPE (AVE_U_DEC, MAG_NONE, OPIHI_FLT); 326 if (!strcasecmp (fieldName, "duRA")) ESCAPE (AVE_U_RA_ERR, MAG_NONE, OPIHI_FLT); 327 if (!strcasecmp (fieldName, "duDEC")) ESCAPE (AVE_U_DEC_ERR, MAG_NONE, OPIHI_FLT); 328 if (!strcasecmp (fieldName, "PAR")) ESCAPE (AVE_PAR, MAG_NONE, OPIHI_FLT); 329 if (!strcasecmp (fieldName, "dPAR")) ESCAPE (AVE_PAR_ERR, MAG_NONE, OPIHI_FLT); 330 if (!strcasecmp (fieldName, "ChiSqPos")) ESCAPE (AVE_CHISQ_POS, MAG_NONE, OPIHI_FLT); 331 if (!strcasecmp (fieldName, "ChiSqPM")) ESCAPE (AVE_CHISQ_PM, MAG_NONE, OPIHI_FLT); 332 if (!strcasecmp (fieldName, "ChiSqPar")) ESCAPE (AVE_CHISQ_PAR, MAG_NONE, OPIHI_FLT); 333 if (!strcasecmp (fieldName, "Tmean")) ESCAPE (AVE_TMEAN, MAG_NONE, OPIHI_FLT); 334 if (!strcasecmp (fieldName, "Trange")) ESCAPE (AVE_TRANGE, MAG_NONE, OPIHI_FLT); 335 if (!strcasecmp (fieldName, "NMEAS")) ESCAPE (AVE_NMEAS, MAG_NONE, OPIHI_INT); 336 if (!strcasecmp (fieldName, "NMISS")) ESCAPE (AVE_NMISS, MAG_NONE, OPIHI_INT); 337 if (!strcasecmp (fieldName, "NPOS")) ESCAPE (AVE_NPOS, MAG_NONE, OPIHI_INT); 338 if (!strcasecmp (fieldName, "NASTROM")) ESCAPE (AVE_NPOS, MAG_NONE, OPIHI_INT); 339 if (!strcasecmp (fieldName, "FLAGS")) ESCAPE (AVE_OBJ_FLAGS, MAG_NONE, OPIHI_INT); 340 if (!strcasecmp (fieldName, "OBJ_FLAGS")) ESCAPE (AVE_OBJ_FLAGS, MAG_NONE, OPIHI_INT); 341 if (!strcasecmp (fieldName, "OBJFLAGS")) ESCAPE (AVE_OBJ_FLAGS, MAG_NONE, OPIHI_INT); 342 if (!strcasecmp (fieldName, "OBJID")) ESCAPE (AVE_OBJID, MAG_NONE, OPIHI_INT); 343 if (!strcasecmp (fieldName, "CATID")) ESCAPE (AVE_CATID, MAG_NONE, OPIHI_INT); 344 if (!strcasecmp (fieldName, "EXTID_HI")) ESCAPE (AVE_EXTID_HI, MAG_NONE, OPIHI_INT); 345 if (!strcasecmp (fieldName, "EXTID_LO")) ESCAPE (AVE_EXTID_LO, MAG_NONE, OPIHI_INT); 348 if (!strcasecmp (fieldName, "RA")) ESCAPE (AVE_RA, MAG_NONE, OPIHI_FLT); 349 if (!strcasecmp (fieldName, "DEC")) ESCAPE (AVE_DEC, MAG_NONE, OPIHI_FLT); 350 if (!strcasecmp (fieldName, "GLON")) ESCAPE (AVE_GLON, MAG_NONE, OPIHI_FLT); 351 if (!strcasecmp (fieldName, "GLAT")) ESCAPE (AVE_GLAT, MAG_NONE, OPIHI_FLT); 352 if (!strcasecmp (fieldName, "ELON")) ESCAPE (AVE_ELON, MAG_NONE, OPIHI_FLT); 353 if (!strcasecmp (fieldName, "ELAT")) ESCAPE (AVE_ELAT, MAG_NONE, OPIHI_FLT); 354 if (!strcasecmp (fieldName, "dRA")) ESCAPE (AVE_RA_ERR, MAG_NONE, OPIHI_FLT); 355 if (!strcasecmp (fieldName, "dDEC")) ESCAPE (AVE_DEC_ERR, MAG_NONE, OPIHI_FLT); 356 if (!strcasecmp (fieldName, "uRA")) ESCAPE (AVE_U_RA, MAG_NONE, OPIHI_FLT); 357 if (!strcasecmp (fieldName, "uDEC")) ESCAPE (AVE_U_DEC, MAG_NONE, OPIHI_FLT); 358 if (!strcasecmp (fieldName, "duRA")) ESCAPE (AVE_U_RA_ERR, MAG_NONE, OPIHI_FLT); 359 if (!strcasecmp (fieldName, "duDEC")) ESCAPE (AVE_U_DEC_ERR, MAG_NONE, OPIHI_FLT); 360 if (!strcasecmp (fieldName, "PAR")) ESCAPE (AVE_PAR, MAG_NONE, OPIHI_FLT); 361 if (!strcasecmp (fieldName, "dPAR")) ESCAPE (AVE_PAR_ERR, MAG_NONE, OPIHI_FLT); 362 if (!strcasecmp (fieldName, "ChiSqPos")) ESCAPE (AVE_CHISQ_POS, MAG_NONE, OPIHI_FLT); 363 if (!strcasecmp (fieldName, "ChiSqPM")) ESCAPE (AVE_CHISQ_PM, MAG_NONE, OPIHI_FLT); 364 if (!strcasecmp (fieldName, "ChiSqPar")) ESCAPE (AVE_CHISQ_PAR, MAG_NONE, OPIHI_FLT); 365 if (!strcasecmp (fieldName, "Tmean")) ESCAPE (AVE_TMEAN, MAG_NONE, OPIHI_FLT); 366 if (!strcasecmp (fieldName, "Trange")) ESCAPE (AVE_TRANGE, MAG_NONE, OPIHI_FLT); 367 if (!strcasecmp (fieldName, "psfqf")) ESCAPE (AVE_PSF_QF, MAG_NONE, OPIHI_FLT); 368 if (!strcasecmp (fieldName, "psfqfperf")) ESCAPE (AVE_PSF_QF_PERF, MAG_NONE, OPIHI_FLT); 369 if (!strcasecmp (fieldName, "psf_qf")) ESCAPE (AVE_PSF_QF, MAG_NONE, OPIHI_FLT); 370 if (!strcasecmp (fieldName, "psf_qf_perf")) ESCAPE (AVE_PSF_QF_PERF, MAG_NONE, OPIHI_FLT); 371 if (!strcasecmp (fieldName, "stargal")) ESCAPE (AVE_STARGAL, MAG_NONE, OPIHI_FLT); 372 if (!strcasecmp (fieldName, "NMEAS")) ESCAPE (AVE_NMEAS, MAG_NONE, OPIHI_INT); 373 if (!strcasecmp (fieldName, "NMISS")) ESCAPE (AVE_NMISS, MAG_NONE, OPIHI_INT); 374 if (!strcasecmp (fieldName, "NPOS")) ESCAPE (AVE_NPOS, MAG_NONE, OPIHI_INT); 375 if (!strcasecmp (fieldName, "NASTROM")) ESCAPE (AVE_NPOS, MAG_NONE, OPIHI_INT); 376 if (!strcasecmp (fieldName, "FLAGS")) ESCAPE (AVE_OBJ_FLAGS, MAG_NONE, OPIHI_INT); 377 if (!strcasecmp (fieldName, "OBJ_FLAGS")) ESCAPE (AVE_OBJ_FLAGS, MAG_NONE, OPIHI_INT); 378 if (!strcasecmp (fieldName, "OBJFLAGS")) ESCAPE (AVE_OBJ_FLAGS, MAG_NONE, OPIHI_INT); 379 if (!strcasecmp (fieldName, "OBJID")) ESCAPE (AVE_OBJID, MAG_NONE, OPIHI_INT); 380 if (!strcasecmp (fieldName, "CATID")) ESCAPE (AVE_CATID, MAG_NONE, OPIHI_INT); 381 if (!strcasecmp (fieldName, "EXTID_HI")) ESCAPE (AVE_EXTID_HI, MAG_NONE, OPIHI_INT); 382 if (!strcasecmp (fieldName, "EXTID_LO")) ESCAPE (AVE_EXTID_LO, MAG_NONE, OPIHI_INT); 346 383 347 384 // check for code:mode in photcode name -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_catalog.c
r35416 r36680 119 119 average->measureOffset = -1; 120 120 average->catID = 0; 121 average->nOwn = 0; 121 122 } 122 123 … … 242 243 measure->dYccd = 0; 243 244 measure->dRsys = 0; 245 measure->myDet = FALSE; 244 246 } 245 247 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_convert.c
r35172 r36680 65 65 } 66 66 67 // block to convert broken tables (PS1_V4 made before the Xfix addition) 68 if (!strcmp (extname, "DVO_AVERAGE_PS1_V4") && (ftable[0].header[0].Naxis[0] == 120)) { 69 Average_PS1_V4alt *tmpAverage; 70 tmpAverage = gfits_table_get_Average_PS1_V4alt (ftable, Naverage, NULL); 71 if (!tmpAverage) { 72 fprintf (stderr, "ERROR: failed to read averages\n"); 73 exit (2); 74 } 75 average = Average_PS1_V4alt_ToInternal (tmpAverage, *Naverage); 76 free (tmpAverage); 77 *format = DVO_FORMAT_PS1_V4; 78 return (average); 79 } 80 67 81 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 68 82 if (!strcmp (extname, NAME)) { \ … … 154 168 fprintf (stderr, "EXTNAME missing for measure table\n"); 155 169 return (FALSE); 170 } 171 172 // block to convert broken tables (PS1_V4 made before the Xfix addition) 173 if (!strcmp (extname, "DVO_MEASURE_PS1_V4") && (ftable[0].header[0].Naxis[0] == 176)) { 174 fprintf (stderr, "reading alt PS1_V4 format\n"); 175 Measure_PS1_V4alt *tmpMeasure; 176 tmpMeasure = gfits_table_get_Measure_PS1_V4alt (ftable, Nmeasure, NULL); 177 if (!tmpMeasure) { 178 fprintf (stderr, "ERROR: failed to read measures\n"); 179 exit (2); 180 } 181 measure = Measure_PS1_V4alt_ToInternal (tmpMeasure, *Nmeasure); 182 free (tmpMeasure); 183 *format = DVO_FORMAT_PS1_V4; 184 return (measure); 156 185 } 157 186 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_convert_PS1_V4.c
r35162 r36680 481 481 return (out); 482 482 } 483 484 /*** there are some mini dvodbs with the wrong PS1_V4 format (missing Xoff,Yoff / Xfix,Yfix) ************/ 485 486 Measure *Measure_PS1_V4alt_ToInternal (Measure_PS1_V4alt *in, off_t Nvalues) { 487 488 off_t i; 489 Measure *out; 490 491 ALLOCATE_ZERO (out, Measure, Nvalues); 492 493 for (i = 0; i < Nvalues; i++) { 494 dvo_measure_init (&out[i]); 495 496 out[i].dR = in[i].dR; 497 out[i].dD = in[i].dD; 498 out[i].M = in[i].M; 499 out[i].Mcal = in[i].Mcal; 500 out[i].Map = in[i].Map; 501 out[i].Mkron = in[i].Mkron; 502 out[i].dMkron = in[i].dMkron; 503 out[i].dM = in[i].dM; 504 out[i].dMcal = in[i].dMcal; 505 out[i].dt = in[i].dt; 506 out[i].FluxPSF = in[i].FluxPSF; 507 out[i].dFluxPSF = in[i].dFluxPSF; 508 out[i].FluxKron = in[i].FluxKron; 509 out[i].dFluxKron = in[i].dFluxKron; 510 out[i].airmass = in[i].airmass; 511 out[i].az = in[i].az; 512 out[i].Xccd = in[i].Xccd; 513 out[i].Yccd = in[i].Yccd; 514 out[i].Xfix = in[i].Xccd; 515 out[i].Yfix = in[i].Yccd; 516 out[i].Sky = in[i].Sky; 517 out[i].dSky = in[i].dSky; 518 out[i].t = in[i].t; 519 out[i].t_msec = in[i].t_msec; 520 out[i].averef = in[i].averef; 521 out[i].detID = in[i].detID; 522 out[i].imageID = in[i].imageID; 523 out[i].objID = in[i].objID; 524 out[i].catID = in[i].catID; 525 out[i].extID = in[i].extID; 526 out[i].psfQF = in[i].psfQF; 527 out[i].psfQFperf = in[i].psfQFperf; 528 out[i].psfChisq = in[i].psfChisq; 529 out[i].psfNdof = in[i].psfNdof; 530 out[i].psfNpix = in[i].psfNpix; 531 out[i].crNsigma = in[i].crNsigma; 532 out[i].extNsigma = in[i].extNsigma; 533 out[i].FWx = in[i].FWx; 534 out[i].FWy = in[i].FWy; 535 out[i].theta = in[i].theta; 536 out[i].Mxx = in[i].Mxx; 537 out[i].Mxy = in[i].Mxy; 538 out[i].Myy = in[i].Myy; 539 out[i].dXccd = in[i].dXccd; 540 out[i].dYccd = in[i].dYccd; 541 out[i].dRsys = in[i].dRsys; 542 out[i].posangle = in[i].posangle; 543 out[i].pltscale = in[i].pltscale; 544 out[i].photcode = in[i].photcode; 545 out[i].dbFlags = in[i].dbFlags; 546 out[i].photFlags = in[i].photFlags; 547 } 548 return (out); 549 } 550 551 // XXX note that there are 2 bad versions of PS1_V4 : the other one does have have PSF_QF_PERFECT, but has PAD instead 552 int gfits_convert_Measure_PS1_V4alt (Measure_PS1_V4alt *data, off_t size, off_t nitems) { 553 554 off_t i; 555 unsigned char *byte, tmp; 556 557 if (size != 176) { 558 fprintf (stderr, "WARNING: mismatch in data types Measure_PS1_V4alt: "OFF_T_FMT" vs %d\n", size, 176); 559 return (FALSE); 560 } 561 562 /* provide initial values to avoid compiler warnings for non-BYTE_SWAP arch */ 563 i = tmp = 0; 564 byte = NULL; 565 566 # ifdef BYTE_SWAP 567 byte = (unsigned char *) data; 568 for (i = 0; i < nitems; i++, byte += 176) { 569 /** BYTE SWAP **/ 570 SWAP_WORD (0); // D_RA 571 SWAP_WORD (4); // D_DEC 572 SWAP_WORD (8); // MAG 573 SWAP_WORD (12); // M_CAL 574 SWAP_WORD (16); // M_APER 575 SWAP_WORD (20); // M_KRON 576 SWAP_WORD (24); // M_KRON_ERR 577 SWAP_WORD (28); // MAG_ERR 578 SWAP_WORD (32); // MAG_CAL_ERR 579 SWAP_WORD (36); // M_TIME 580 SWAP_WORD (40); // FLUX_PSF 581 SWAP_WORD (44); // FLUX_PSF_ERR 582 SWAP_WORD (48); // FLUX_KRON 583 SWAP_WORD (52); // FLUX_KRON_ERR 584 SWAP_WORD (56); // AIRMASS 585 SWAP_WORD (60); // AZ 586 SWAP_WORD (64); // X_CCD 587 SWAP_WORD (68); // Y_CCD 588 SWAP_WORD (72); // SKY_FLUX 589 SWAP_WORD (76); // SKY_FLUX_ERR 590 SWAP_WORD (80); // TIME 591 SWAP_WORD (84); // AVE_REF 592 SWAP_WORD (88); // DET_ID 593 SWAP_WORD (92); // IMAGE_ID 594 SWAP_WORD (96); // OBJ_ID 595 SWAP_WORD (100); // CAT_ID 596 SWAP_DBLE (104); // EXT_ID 597 SWAP_WORD (112); // PSF_QF 598 SWAP_WORD (116); // PSF_QF_PERFECT 599 SWAP_WORD (120); // PSF_CHISQ 600 SWAP_WORD (124); // PSF_NDOF 601 SWAP_WORD (128); // PSF_NPIX 602 SWAP_WORD (132); // CR_NSIGMA 603 SWAP_WORD (136); // EXT_NSIGMA 604 SWAP_BYTE (140); // FWHM_MAJOR 605 SWAP_BYTE (142); // FWHM_MINOR 606 SWAP_BYTE (144); // PSF_THETA 607 SWAP_BYTE (146); // MXX 608 SWAP_BYTE (148); // MXY 609 SWAP_BYTE (150); // MYY 610 SWAP_BYTE (152); // TIME_MSEC 611 SWAP_BYTE (154); // PHOTCODE 612 SWAP_BYTE (156); // X_CCD_ERR 613 SWAP_BYTE (158); // Y_CCD_ERR 614 SWAP_BYTE (160); // POS_SYS_ERR 615 SWAP_BYTE (162); // POSANGLE 616 SWAP_WORD (164); // PLTSCALE 617 SWAP_WORD (168); // DB_FLAGS 618 SWAP_WORD (172); // PHOT_FLAGS 619 } 620 # endif 621 622 return (TRUE); 623 } 624 625 /*** add test of EXTNAME and header-defined columns? ***/ 626 /* return internal structure representation */ 627 Measure_PS1_V4alt *gfits_table_get_Measure_PS1_V4alt (FTable *ftable, off_t *Ndata, char *swapped) { 628 629 int Ncols; 630 Measure_PS1_V4alt *data; 631 632 Ncols = ftable[0].header[0].Naxis[0]; 633 if (Ncols != 176) { 634 fprintf (stderr, "ERROR: mis-match in table size: width is %d but should be %d bytes\n", Ncols, 176); 635 return NULL; 636 } 637 638 *Ndata = ftable[0].header[0].Naxis[1]; 639 data = (Measure_PS1_V4alt *) ftable[0].buffer; 640 if ((swapped == NULL) || (*swapped == FALSE)) { 641 if (!gfits_convert_Measure_PS1_V4alt (data, sizeof (Measure_PS1_V4alt), *Ndata)) { 642 return NULL; 643 } 644 gfits_table_scale_data (ftable); 645 if (swapped != NULL) *swapped = TRUE; 646 } 647 return (data); 648 } 649 650 // 'primary' is needed to conform with the API for Loneos and Elixir, but is not used 651 Average *Average_PS1_V4alt_ToInternal (Average_PS1_V4alt *in, off_t Nvalues) { 652 653 off_t i; 654 Average *out; 655 656 ALLOCATE_ZERO (out, Average, Nvalues); 657 658 for (i = 0; i < Nvalues; i++) { 659 dvo_average_init (&out[i]); 660 661 out[i].R = in[i].R; 662 out[i].D = in[i].D; 663 out[i].dR = in[i].dR; 664 out[i].dD = in[i].dD; 665 out[i].uR = in[i].uR; 666 out[i].uD = in[i].uD; 667 out[i].duR = in[i].duR; 668 out[i].duD = in[i].duD; 669 out[i].P = in[i].P; 670 out[i].dP = in[i].dP; 671 out[i].ChiSqAve = in[i].ChiSqAve; 672 out[i].ChiSqPM = in[i].ChiSqPM; 673 out[i].ChiSqPar = in[i].ChiSqPar; 674 out[i].Tmean = in[i].Tmean; 675 out[i].Trange = in[i].Trange; 676 out[i].Npos = in[i].Npos; 677 out[i].Nmeasure = in[i].Nmeasure; 678 out[i].Nmissing = in[i].Nmissing; 679 out[i].Nextend = in[i].Nextend; 680 out[i].measureOffset = in[i].measureOffset; 681 out[i].missingOffset = in[i].missingOffset; 682 out[i].extendOffset = in[i].extendOffset; 683 out[i].flags = in[i].flags; 684 out[i].photFlagsUpper = in[i].photFlagsUpper; 685 out[i].photFlagsLower = in[i].photFlagsLower; 686 out[i].objID = in[i].objID; 687 out[i].catID = in[i].catID; 688 out[i].extID = in[i].extID; 689 } 690 return (out); 691 } 692 693 /******/ 694 695 int gfits_convert_Average_PS1_V4alt (Average_PS1_V4alt *data, off_t size, off_t nitems) { 696 697 off_t i; 698 unsigned char *byte, tmp; 699 700 if (size != 120) { 701 fprintf (stderr, "WARNING: mismatch in data types Average_PS1_V4alt: "OFF_T_FMT" vs %d\n", size, 120); 702 return (FALSE); 703 } 704 705 /* provide initial values to avoid compiler warnings for non-BYTE_SWAP arch */ 706 i = tmp = 0; 707 byte = NULL; 708 709 # ifdef BYTE_SWAP 710 byte = (unsigned char *) data; 711 for (i = 0; i < nitems; i++, byte += 120) { 712 /** BYTE SWAP **/ 713 SWAP_DBLE (0); // RA 714 SWAP_DBLE (8); // DEC 715 SWAP_WORD (16); // RA_ERR 716 SWAP_WORD (20); // DEC_ERR 717 SWAP_WORD (24); // U_RA 718 SWAP_WORD (28); // U_DEC 719 SWAP_WORD (32); // V_RA_ERR 720 SWAP_WORD (36); // V_DEC_ERR 721 SWAP_WORD (40); // PAR 722 SWAP_WORD (44); // PAR_ERR 723 SWAP_WORD (48); // CHISQ_POS 724 SWAP_WORD (52); // CHISQ_PM 725 SWAP_WORD (56); // CHISQ_PAP 726 SWAP_WORD (60); // MEAN_EPOCH 727 SWAP_WORD (64); // TIME_RANGE 728 SWAP_WORD (68); // SIGMA 729 SWAP_BYTE (72); // NUMBER_POS 730 SWAP_BYTE (74); // NMEASURE 731 SWAP_BYTE (76); // NMISSING 732 SWAP_BYTE (78); // NEXTEND 733 SWAP_WORD (80); // OFF_MEASURE 734 SWAP_WORD (84); // OFF_MISSING 735 SWAP_WORD (88); // OFF_EXTEND 736 SWAP_WORD (92); // FLAGS 737 SWAP_WORD (96); // PHOTFLAGS_U 738 SWAP_WORD (100); // PHOTFLAGS_L 739 SWAP_WORD (104); // OBJ_ID 740 SWAP_WORD (108); // CAT_ID 741 SWAP_DBLE (112); // EXT_ID 742 } 743 # endif 744 745 return (TRUE); 746 } 747 748 /*** add test of EXTNAME and header-defined columns? ***/ 749 /* return internal structure representation */ 750 Average_PS1_V4alt *gfits_table_get_Average_PS1_V4alt (FTable *ftable, off_t *Ndata, char *swapped) { 751 752 int Ncols; 753 Average_PS1_V4alt *data; 754 755 Ncols = ftable[0].header[0].Naxis[0]; 756 if (Ncols != 120) { 757 fprintf (stderr, "ERROR: mis-match in table size: width is %d but should be %d bytes\n", Ncols, 120); 758 return NULL; 759 } 760 761 *Ndata = ftable[0].header[0].Naxis[1]; 762 data = (Average_PS1_V4alt *) ftable[0].buffer; 763 if ((swapped == NULL) || (*swapped == FALSE)) { 764 if (!gfits_convert_Average_PS1_V4alt (data, sizeof (Average_PS1_V4alt), *Ndata)) { 765 return NULL; 766 } 767 gfits_table_scale_data (ftable); 768 if (swapped != NULL) *swapped = TRUE; 769 } 770 return (data); 771 } 772 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_photcode_ops.c
r34844 r36680 169 169 } 170 170 171 // returns Nsec if code is PRI/SEC, else -1 171 172 int GetPhotcodeNsec (int code) { 172 173 … … 259 260 } 260 261 261 float PhotAper (Measure *measure) {262 263 int Np;264 float Mcat;265 PhotCode *code;266 267 Np = photcodes[0].hashcode[measure[0].photcode];268 if (Np == -1) return (NAN);269 270 if (photcodes[0].code[Np].type == PHOT_REF) {271 Mcat = measure[0].Map;272 return (Mcat);273 }274 code = &photcodes[0].code[Np];275 Mcat = measure[0].Map - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C;276 277 return (Mcat);278 }279 280 float PhotAperInst (Measure *measure) {281 282 int Np;283 float Minst;284 285 Np = photcodes[0].hashcode[measure[0].photcode];286 if (Np == -1) return (NAN);287 288 if (photcodes[0].code[Np].type == PHOT_REF) {289 Minst = measure[0].Map;290 return (Minst);291 }292 Minst = measure[0].Map - measure[0].dt - ZERO_POINT;293 294 return (Minst);295 }296 297 float PhotKron (Measure *measure) {298 299 int Np;300 float Mcat;301 PhotCode *code;302 303 Np = photcodes[0].hashcode[measure[0].photcode];304 if (Np == -1) return (NAN);305 306 if (photcodes[0].code[Np].type == PHOT_REF) {307 Mcat = measure[0].Mkron;308 return (Mcat);309 }310 code = &photcodes[0].code[Np];311 Mcat = measure[0].Mkron - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C;312 313 return (Mcat);314 }315 316 float PhotKronInst (Measure *measure) {317 318 int Np;319 float Minst;320 321 Np = photcodes[0].hashcode[measure[0].photcode];322 if (Np == -1) return (NAN);323 324 if (photcodes[0].code[Np].type == PHOT_REF) {325 Minst = measure[0].Mkron;326 return (Minst);327 }328 Minst = measure[0].Mkron - measure[0].dt - ZERO_POINT;329 330 return (Minst);331 }332 333 262 float PhotSys (Measure *measure, Average *average, SecFilt *secfilt) { 334 263 … … 362 291 } 363 292 364 float PhotZeroPoint (Measure *measure, Average *average, SecFilt *secfilt) {365 366 int Np;367 float ZP;368 PhotCode *code;369 370 Np = photcodes[0].hashcode[measure[0].photcode];371 if (Np == -1) return (NAN);372 373 if (photcodes[0].code[Np].type == PHOT_REF) {374 ZP = 0.0;375 return (ZP);376 }377 code = &photcodes[0].code[Np];378 ZP = code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C;379 380 return (ZP);381 }382 383 293 float PhotRel (Measure *measure, Average *average, SecFilt *secfilt) { 384 294 … … 444 354 Mcal += Mcol; 445 355 return (Mcal); 356 } 357 358 /***/ 359 float PhotAve (PhotCode *code, Average *average, SecFilt *secfilt) { 360 361 int Ns; 362 float Mave; 363 364 if (code == NULL) return NAN; 365 366 Ns = photcodes[0].hashNsec[code[0].code]; 367 Mave = (Ns == -1) ? NAN : secfilt[Ns].M; 368 return (Mave); 369 } 370 371 /* return calibrated magnitude from average/secfilt for given photcode */ 372 float PhotRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure) { 373 374 int i, Ns; 375 float Mave, Mref, Mcol, mc; 376 double Mc; 377 378 if (code == NULL) return NAN; 379 380 Ns = photcodes[0].hashNsec[code[0].code]; 381 Mave = (Ns == -1) ? NAN : secfilt[Ns].M; 382 Mref = Mave + SCALE*code[0].C; 383 384 mc = PhotColorForCode (average, secfilt, measure, code); 385 if (isnan(mc)) return (Mref); 386 mc = mc - SCALE*code[0].dX; 387 388 Mc = mc; 389 Mcol = 0; 390 for (i = 0; i < code[0].Nc; i++) { 391 Mcol += code[0].X[i]*Mc; 392 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */ 393 } 394 Mref += Mcol; 395 return (Mref); 396 } 397 398 float PhotAveErr (PhotCode *code, Average *average, SecFilt *secfilt) { 399 400 int Ns; 401 float dM; 402 403 if (code == NULL) return NAN; 404 405 Ns = photcodes[0].hashNsec[code[0].code]; 406 dM = (Ns == -1) ? NAN : secfilt[Ns].dM; 407 return (dM); 408 } 409 410 /************************************** APERTURE-related Magnitudes ***********************************************/ 411 412 float PhotAperInst (Measure *measure) { 413 414 int Np; 415 float Minst; 416 417 Np = photcodes[0].hashcode[measure[0].photcode]; 418 if (Np == -1) return (NAN); 419 420 if (photcodes[0].code[Np].type == PHOT_REF) { 421 Minst = measure[0].Map; 422 return (Minst); 423 } 424 Minst = measure[0].Map - measure[0].dt - ZERO_POINT; 425 426 return (Minst); 427 } 428 429 float PhotAperCat (Measure *measure) { 430 431 int Np; 432 float Mcat; 433 PhotCode *code; 434 435 Np = photcodes[0].hashcode[measure[0].photcode]; 436 if (Np == -1) return (NAN); 437 438 if (photcodes[0].code[Np].type == PHOT_REF) { 439 Mcat = measure[0].Map; 440 return (Mcat); 441 } 442 code = &photcodes[0].code[Np]; 443 Mcat = measure[0].Map - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 444 445 return (Mcat); 446 } 447 448 float PhotAperSys (Measure *measure, Average *average, SecFilt *secfilt) { 449 450 int i, Np; 451 float Mcat, Mcol, Msys, mc, Mc; 452 PhotCode *code; 453 454 Np = photcodes[0].hashcode[measure[0].photcode]; 455 if (Np == -1) return (NAN); 456 457 if (photcodes[0].code[Np].type == PHOT_REF) { 458 Mcat = measure[0].Map; 459 return (Mcat); 460 } 461 code = &photcodes[0].code[Np]; 462 Mcat = measure[0].Map - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 463 464 /* for DEP, color must be made of PRI/SEC */ 465 mc = PhotColorForCode (average, secfilt, NULL, code); 466 if (isnan(mc)) return (Mcat); 467 mc = mc - SCALE*code[0].dX; 468 469 Mc = mc; 470 Mcol = 0; 471 for (i = 0; i < code[0].Nc; i++) { 472 Mcol += code[0].X[i]*Mc; 473 Mc *= mc; 474 } 475 Msys = Mcat + Mcol; 476 return (Msys); 477 } 478 479 float PhotAperRel (Measure *measure, Average *average, SecFilt *secfilt) { 480 481 int i, Np; 482 float Mcat, Mcol, Mrel, mc, Mc; 483 PhotCode *code; 484 485 Np = photcodes[0].hashcode[measure[0].photcode]; 486 if (Np == -1) return (NAN); 487 488 if (photcodes[0].code[Np].type == PHOT_REF) { 489 Mcat = measure[0].Map; 490 return (Mcat); 491 } 492 code = &photcodes[0].code[Np]; 493 Mrel = measure[0].Map - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C - measure[0].Mcal; 494 495 /* for DEP, color must be made of PRI/SEC */ 496 mc = PhotColorForCode (average, secfilt, NULL, code); 497 if (isnan(mc)) return (Mrel); 498 mc = mc - SCALE*code[0].dX; 499 500 Mc = mc; 501 Mcol = 0; 502 for (i = 0; i < code[0].Nc; i++) { 503 Mcol += code[0].X[i]*Mc; 504 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */ 505 } 506 Mrel += Mcol; 507 return (Mrel); 508 } 509 510 /* return calibrated magnitude from measure for given photcode */ 511 float PhotAperCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code) { 512 513 int i, Np; 514 float Mcal, Mrel, Mcol, mc, Mc; 515 516 if (code == NULL) return NAN; 517 518 /* code must be the matching PRI/SEC code for this measurement or an equivalent ALT */ 519 Np = photcodes[0].hashcode[thisone[0].photcode]; 520 if (Np == -1) return (NAN); 521 522 if (photcodes[0].code[Np].type == PHOT_REF) { 523 Mrel = thisone[0].Map; 524 return (Mrel); 525 } 526 if (code[0].code != photcodes[0].code[Np].equiv) return (NAN); 527 528 Mcal = PhotAperRel (thisone, average, secfilt) + SCALE*code[0].C; 529 530 mc = PhotColorForCode (average, secfilt, measure, code); 531 if (isnan(mc)) return (Mcal); 532 mc = mc - SCALE*code[0].dX; 533 534 Mc = mc; 535 Mcol = 0; 536 for (i = 0; i < code[0].Nc; i++) { 537 Mcol += code[0].X[i]*Mc; 538 Mc *= mc; 539 } 540 Mcal += Mcol; 541 return (Mcal); 542 } 543 544 float PhotAperAve (PhotCode *code, Average *average, SecFilt *secfilt) { 545 546 int Ns; 547 float Maper; 548 549 if (code == NULL) return NAN; 550 551 Ns = photcodes[0].hashNsec[code[0].code]; 552 Maper = (Ns == -1) ? NAN : secfilt[Ns].Map; 553 return (Maper); 554 } 555 556 /* return calibrated magnitude from average/secfilt for given photcode */ 557 float PhotAperRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure) { 558 559 int i, Ns; 560 float Mave, Mref, Mcol, mc; 561 double Mc; 562 563 if (code == NULL) return NAN; 564 565 Ns = photcodes[0].hashNsec[code[0].code]; 566 Mave = (Ns == -1) ? NAN : secfilt[Ns].Map; 567 Mref = Mave + SCALE*code[0].C; 568 569 mc = PhotColorForCode (average, secfilt, measure, code); 570 if (isnan(mc)) return (Mref); 571 mc = mc - SCALE*code[0].dX; 572 573 Mc = mc; 574 Mcol = 0; 575 for (i = 0; i < code[0].Nc; i++) { 576 Mcol += code[0].X[i]*Mc; 577 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */ 578 } 579 Mref += Mcol; 580 return (Mref); 581 } 582 583 /************************************** KRON-related Magnitudes ***********************************************/ 584 585 float PhotKronInst (Measure *measure) { 586 587 int Np; 588 float Minst; 589 590 Np = photcodes[0].hashcode[measure[0].photcode]; 591 if (Np == -1) return (NAN); 592 593 if (photcodes[0].code[Np].type == PHOT_REF) { 594 Minst = measure[0].Mkron; 595 return (Minst); 596 } 597 Minst = measure[0].Mkron - measure[0].dt - ZERO_POINT; 598 599 return (Minst); 600 } 601 602 float PhotKronCat (Measure *measure) { 603 604 int Np; 605 float Mcat; 606 PhotCode *code; 607 608 Np = photcodes[0].hashcode[measure[0].photcode]; 609 if (Np == -1) return (NAN); 610 611 if (photcodes[0].code[Np].type == PHOT_REF) { 612 Mcat = measure[0].Mkron; 613 return (Mcat); 614 } 615 code = &photcodes[0].code[Np]; 616 Mcat = measure[0].Mkron - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 617 618 return (Mcat); 619 } 620 621 float PhotKronSys (Measure *measure, Average *average, SecFilt *secfilt) { 622 623 int i, Np; 624 float Mcat, Mcol, Msys, mc, Mc; 625 PhotCode *code; 626 627 Np = photcodes[0].hashcode[measure[0].photcode]; 628 if (Np == -1) return (NAN); 629 630 if (photcodes[0].code[Np].type == PHOT_REF) { 631 Msys = measure[0].Mkron; 632 return (Msys); 633 } 634 code = &photcodes[0].code[Np]; 635 Mcat = measure[0].Mkron - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 636 637 /* for DEP, color must be made of PRI/SEC */ 638 mc = PhotColorForCode (average, secfilt, NULL, code); 639 if (isnan(mc)) return (Mcat); 640 mc = mc - SCALE*code[0].dX; 641 642 Mc = mc; 643 Mcol = 0; 644 for (i = 0; i < code[0].Nc; i++) { 645 Mcol += code[0].X[i]*Mc; 646 Mc *= mc; 647 } 648 Msys = Mcat + Mcol; 649 return (Msys); 650 } 651 652 float PhotKronRel (Measure *measure, Average *average, SecFilt *secfilt) { 653 654 int i, Np; 655 float Mcat, Mcol, Mrel, mc, Mc; 656 PhotCode *code; 657 658 Np = photcodes[0].hashcode[measure[0].photcode]; 659 if (Np == -1) return (NAN); 660 661 if (photcodes[0].code[Np].type == PHOT_REF) { 662 Mcat = measure[0].Mkron; 663 return (Mcat); 664 } 665 code = &photcodes[0].code[Np]; 666 Mrel = measure[0].Mkron - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C - measure[0].Mcal; 667 668 /* for DEP, color must be made of PRI/SEC */ 669 mc = PhotColorForCode (average, secfilt, NULL, code); 670 if (isnan(mc)) return (Mrel); 671 mc = mc - SCALE*code[0].dX; 672 673 Mc = mc; 674 Mcol = 0; 675 for (i = 0; i < code[0].Nc; i++) { 676 Mcol += code[0].X[i]*Mc; 677 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */ 678 } 679 Mrel += Mcol; 680 return (Mrel); 681 } 682 683 /* return calibrated magnitude from measure for given photcode */ 684 float PhotKronCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code) { 685 686 int i, Np; 687 float Mcal, Mrel, Mcol, mc, Mc; 688 689 if (code == NULL) return NAN; 690 691 /* code must be the matching PRI/SEC code for this measurement or an equivalent ALT */ 692 Np = photcodes[0].hashcode[thisone[0].photcode]; 693 if (Np == -1) return (NAN); 694 695 if (photcodes[0].code[Np].type == PHOT_REF) { 696 Mrel = thisone[0].Mkron; 697 return (Mrel); 698 } 699 if (code[0].code != photcodes[0].code[Np].equiv) return (NAN); 700 701 Mcal = PhotKronRel (thisone, average, secfilt) + SCALE*code[0].C; 702 703 mc = PhotColorForCode (average, secfilt, measure, code); 704 if (isnan(mc)) return (Mcal); 705 mc = mc - SCALE*code[0].dX; 706 707 Mc = mc; 708 Mcol = 0; 709 for (i = 0; i < code[0].Nc; i++) { 710 Mcol += code[0].X[i]*Mc; 711 Mc *= mc; 712 } 713 Mcal += Mcol; 714 return (Mcal); 715 } 716 717 float PhotKronAve (PhotCode *code, Average *average, SecFilt *secfilt) { 718 719 int Ns; 720 float Mkron; 721 722 if (code == NULL) return NAN; 723 724 Ns = photcodes[0].hashNsec[code[0].code]; 725 Mkron = (Ns == -1) ? NAN : secfilt[Ns].Mkron; 726 return (Mkron); 727 } 728 729 /* return calibrated magnitude from average/secfilt for given photcode */ 730 float PhotKronRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure) { 731 732 int i, Ns; 733 float Mave, Mref, Mcol, mc; 734 double Mc; 735 736 if (code == NULL) return NAN; 737 738 Ns = photcodes[0].hashNsec[code[0].code]; 739 Mave = (Ns == -1) ? NAN : secfilt[Ns].Mkron; 740 Mref = Mave + SCALE*code[0].C; 741 742 mc = PhotColorForCode (average, secfilt, measure, code); 743 if (isnan(mc)) return (Mref); 744 mc = mc - SCALE*code[0].dX; 745 746 Mc = mc; 747 Mcol = 0; 748 for (i = 0; i < code[0].Nc; i++) { 749 Mcol += code[0].X[i]*Mc; 750 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */ 751 } 752 Mref += Mcol; 753 return (Mref); 754 } 755 756 float PhotKronAveErr (PhotCode *code, Average *average, SecFilt *secfilt) { 757 758 int Ns; 759 float dMkron; 760 761 if (code == NULL) return NAN; 762 763 Ns = photcodes[0].hashNsec[code[0].code]; 764 dMkron = (Ns == -1) ? NAN : secfilt[Ns].dMkron; 765 return (dMkron); 766 } 767 768 /********************* other support functions ********************************/ 769 770 float PhotZeroPoint (Measure *measure, Average *average, SecFilt *secfilt) { 771 772 int Np; 773 float ZP; 774 PhotCode *code; 775 776 Np = photcodes[0].hashcode[measure[0].photcode]; 777 if (Np == -1) return (NAN); 778 779 if (photcodes[0].code[Np].type == PHOT_REF) { 780 ZP = 0.0; 781 return (ZP); 782 } 783 code = &photcodes[0].code[Np]; 784 ZP = code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 785 786 return (ZP); 446 787 } 447 788 … … 496 837 } 497 838 498 /* return calibrated magnitude from average/secfilt for given photcode */499 float PhotRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure) {500 501 int i, Ns;502 float Mave, Mref, Mcol, mc;503 double Mc;504 505 if (code == NULL) return NAN;506 507 Ns = photcodes[0].hashNsec[code[0].code];508 Mave = (Ns == -1) ? NAN : secfilt[Ns].M;509 Mref = Mave + SCALE*code[0].C;510 511 mc = PhotColorForCode (average, secfilt, measure, code);512 if (isnan(mc)) return (Mref);513 mc = mc - SCALE*code[0].dX;514 515 Mc = mc;516 Mcol = 0;517 for (i = 0; i < code[0].Nc; i++) {518 Mcol += code[0].X[i]*Mc;519 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */520 }521 Mref += Mcol;522 return (Mref);523 }524 525 /***/526 float PhotAve (PhotCode *code, Average *average, SecFilt *secfilt) {527 528 int Ns;529 float Mave;530 531 if (code == NULL) return NAN;532 533 Ns = photcodes[0].hashNsec[code[0].code];534 Mave = (Ns == -1) ? NAN : secfilt[Ns].M;535 return (Mave);536 }537 538 float PhotdM (PhotCode *code, Average *average, SecFilt *secfilt) {539 540 int Ns;541 float dM;542 543 if (code == NULL) return NAN;544 545 Ns = photcodes[0].hashNsec[code[0].code];546 dM = (Ns == -1) ? NAN : secfilt[Ns].dM;547 return (dM);548 }549 550 839 float PhotMstdev (PhotCode *code, Average *average, SecFilt *secfilt) { 551 840 … … 558 847 Mstdev = (Ns == -1) ? NAN : 0.001*secfilt[Ns].Mstdev; 559 848 return (Mstdev); 560 }561 562 float PhotKronAve (PhotCode *code, Average *average, SecFilt *secfilt) {563 564 int Ns;565 float Mkron;566 567 if (code == NULL) return NAN;568 569 Ns = photcodes[0].hashNsec[code[0].code];570 Mkron = (Ns == -1) ? NAN : secfilt[Ns].Mkron;571 return (Mkron);572 }573 574 float PhotKronAveErr (PhotCode *code, Average *average, SecFilt *secfilt) {575 576 int Ns;577 float dMkron;578 579 if (code == NULL) return NAN;580 581 Ns = photcodes[0].hashNsec[code[0].code];582 dMkron = (Ns == -1) ? NAN : secfilt[Ns].dMkron;583 return (dMkron);584 849 } 585 850 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvo_tiny_values.c
r35102 r36680 8 8 averageT[0].measureOffset = average[0].measureOffset; 9 9 averageT[0].catID = average[0].catID; 10 averageT[0].objID = average[0].objID; 11 averageT[0].nOwn = -1; 10 12 return; 11 13 } … … 33 35 measureT[0].dYccd = measure[0].dYccd; 34 36 measureT[0].dRsys = measure[0].dRsys; 37 measureT[0].myDet = 0; 35 38 return ; 36 39 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libdvo/src/dvosorts.c
r35263 r36680 60 60 61 61 /* sort a coordinate pair (X,Y) and the associated index (S) */ 62 void sort_IDs_indexonly (opihi_int *X, off_t *S, off_t N) { 63 64 # define SWAPFUNC(A,B){ off_t itmp; \ 65 itmp = S[A]; S[A] = S[B]; S[B] = itmp; \ 66 } 67 # define COMPARE(A,B)(X[S[A]] < X[S[B]]) 68 69 OHANA_SORT (N, COMPARE, SWAPFUNC); 70 71 # undef SWAPFUNC 72 # undef COMPARE 73 74 } 75 76 /* sort a coordinate pair (X,Y) and the associated index (S) */ 62 77 void sort_coords_indexonly (double *X, double *Y, off_t *S, off_t N) { 63 78 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libfits/table/F_get_column.c
r35101 r36680 174 174 int gfits_get_bintable_column (Header *header, FTable *table, char *label, void **data) { 175 175 176 off_t Nx, Ny; 177 int i, N, Nfields, Nval, Nbytes, Nstart, Nv, Nb; 178 char tlabel[80], field[80], format[80], type[16], tmpline[16]; 179 char *Pin, *Pout, *array; 180 double Bscale, Bzero; 181 182 if (label == (char *) NULL) return (FALSE); 183 if (label[0] == 0) return (FALSE); 184 185 /* find label in header */ 186 tlabel[0] = 0; 187 gfits_scan (header, "TFIELDS", "%d", 1, &Nfields); 188 for (i = 1; strcasecmp (label, tlabel) && (i < Nfields + 1); i++) { 189 sprintf (field, "TTYPE%d", i); 190 gfits_scan (header, field, "%s", 1, tlabel); 191 } 192 if (strcasecmp (label, tlabel)) return (FALSE); 193 N = i - 1; 194 195 Bscale = 1; 196 Bzero = 0; 197 198 /* interpret format */ 199 sprintf (field, "TSCAL%d", N); 200 gfits_scan (header, field, "%lf", 1, &Bscale); 201 sprintf (field, "TZERO%d", N); 202 gfits_scan (header, field, "%lf", 1, &Bzero); 203 sprintf (field, "TFORM%d", N); 204 gfits_scan (header, field, "%s", 1, format); 205 206 if (!gfits_bintable_format (format, type, &Nval, &Nbytes)) return (FALSE); 207 208 /* check existing table dimensions */ 209 gfits_scan (header, "NAXIS1", OFF_T_FMT, 1, &Nx); 210 gfits_scan (header, "NAXIS2", OFF_T_FMT, 1, &Ny); 211 212 /* scan columns to find insert point */ 213 Nstart = 0; 214 for (i = 1; i < N; i++) { 215 sprintf (field, "TFORM%d", i); 216 gfits_scan (header, field, "%s", 1, format); 217 gfits_bintable_format (format, tmpline, &Nv, &Nb); 218 Nstart += Nv*Nb; 219 } 220 221 /* extract bytes from table into temporary array */ 222 ALLOCATE (array, char, Nbytes*Nval*Ny); 223 Pin = table[0].buffer + Nstart; 224 Pout = array; 225 for (i = 0; i < Ny; i++, Pin += Nx, Pout += Nval*Nbytes) { 226 memcpy (Pout, Pin, Nval*Nbytes); 227 } 228 229 /* convert data in-situ with correct type, byte swap and Bzero/Bscale */ 230 Pin = array; 231 Pout = array; 232 if (!strcmp (type, "char")) { 233 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 234 *(char *)Pout = *(char *)Pin*Bscale + Bzero; 235 } 236 } 237 if (!strcmp (type, "short")) { 238 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 239 # ifdef BYTE_SWAP 240 SWAP_BYTE; 241 # endif 242 *(short *)Pout = *(short *)Pin*Bscale + Bzero; 243 } 244 } 245 if (!strcmp (type, "int")) { 246 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 247 # ifdef BYTE_SWAP 248 SWAP_WORD; 249 # endif 250 *(int *)Pout = *(int *)Pin*Bscale + Bzero; 251 } 252 } 253 if (!strcmp (type, "int64_t")) { 254 // XXX 64 bit int operations with Bzero & Bscale are inaccurate even with doubles 255 if ((Bzero == 0.0) && (Bscale == 1.0)) { 256 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 257 # ifdef BYTE_SWAP 258 SWAP_DBLE; 259 # endif 260 *(int64_t *)Pout = *(int64_t *)Pin; 261 } 262 } else { 263 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 264 # ifdef BYTE_SWAP 265 SWAP_DBLE; 266 # endif 267 *(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero; 268 } 269 } 270 } 271 if (!strcmp (type, "float")) { 272 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 273 # ifdef BYTE_SWAP 274 SWAP_WORD; 275 # endif 276 *(float *)Pout = *(float *)Pin*Bscale + Bzero; 277 } 278 } 279 if (!strcmp (type, "double")) { 280 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 281 # ifdef BYTE_SWAP 282 SWAP_DBLE; 283 # endif 284 *(double *)Pout = *(double *)Pin*Bscale + Bzero; 285 } 286 } 176 char type[16]; 177 off_t Nrow; 178 int Ncol; 179 180 char *array = gfits_get_bintable_column_data (header, table, label, type, &Nrow, &Ncol); 181 if (array == NULL) return (FALSE); 287 182 288 183 *data = array; 289 return (TRUE);184 return TRUE; 290 185 } 291 186 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libkapa/src/IOfuncs.c
r35761 r36680 54 54 va_end (argp); 55 55 56 if (!Nbyte) return (FALSE); 56 if (!Nbyte) { 57 KiiSendCommand (device, 16, "LEN: %11d", 0); 58 return (FALSE); 59 } 57 60 58 61 /* the message may contain up to 99,999,999,999 bytes (100MB) */ … … 84 87 /* find the message length, allocate space */ 85 88 sscanf (buffer, "%*s %d", &Nbytes); 89 if (Nbytes == 0) { 90 return TRUE; 91 } 92 86 93 ALLOCATE (message, char, Nbytes + 1); 87 94 memset (message, 0, Nbytes + 1); 95 88 96 89 97 /* read Nbytes from the device */ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libkapa/src/KapaWindow.c
r35761 r36680 100 100 graphdata[0].coords.pc1_1 = graphdata[0].coords.pc2_2 = 1.0; 101 101 graphdata[0].coords.pc1_2 = graphdata[0].coords.pc2_1 = 0.0; 102 strcpy (graphdata[0].coords.ctype, " RA---LIN");102 strcpy (graphdata[0].coords.ctype, "DEC--LIN"); 103 103 graphdata[0].coords.crval1 = 0.0; 104 104 graphdata[0].coords.crval2 = 0.0; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libkapa/src/bDrawFuncs.c
r33956 r36680 247 247 int i; 248 248 249 if (Y < 0) return; 250 if (Y >= buffer[0].Ny) return; 251 249 252 for (i = X1; i < X2; i++) { 253 if (i < 0) continue; 254 if (i >= buffer[0].Nx) continue; 250 255 if (buffer[0].Nbyte == 1) { 251 256 buffer[0].pixels[Y][i] = buffer->bColor; … … 263 268 int i; 264 269 270 if (X < 0) return; 271 if (X >= buffer[0].Nx) return; 272 265 273 for (i = Y1; i < Y2; i++) { 274 if (i < 0) continue; 275 if (i >= buffer[0].Ny) continue; 266 276 if (buffer[0].Nbyte == 1) { 267 277 buffer[0].pixels[i][X] = buffer->bColor; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libohana/src
- Property svn:mergeinfo changed
-
branches/eam_branches/ps2-tc3-20130727/Ohana/src/libohana/src/gaussj.c
r24080 r36680 1 1 # include <ohana.h> 2 2 # define GROWTHTEST 0 3 # define MAX_RANGE 1.0e 73 # define MAX_RANGE 1.0e9 4 4 5 5 // Gauss-Jordan elimination using full pivots based on Press et al's description. Substantially … … 91 91 /* rescale by pivot reciprocal */ 92 92 double tmpval = 1.0 / A[maxcol][maxcol]; 93 // XXX why is this here (don't I double count this element?) A[maxcol][maxcol] = 1.0; 93 94 A[maxcol][maxcol] = 1.0; 94 95 for (col = 0; col < N; col++) A[maxcol][col] *= tmpval; … … 117 118 } 118 119 } 120 121 # if (GROWTHTEST) 122 fprintf (stderr, "final A matrix:\n"); 123 for (row = 0; row < N; row++) { 124 for (col = 0; col < N; col++) { 125 fprintf (stderr, "%10.3e ", A[row][col]); 126 } 127 fprintf (stderr, "\n"); 128 } 129 fprintf (stderr, "\n"); 130 # endif 119 131 120 132 // swap back the inverse matrix based on the row swaps above -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/markrock/src/gcatstats.c
r27435 r36680 40 40 catstats[0].coords.pc1_1 = catstats[0].coords.pc2_2 = 1.0; 41 41 catstats[0].coords.pc1_2 = catstats[0].coords.pc2_1 = 0.0; 42 strcpy (catstats[0].coords.ctype, " RA---TAN");42 strcpy (catstats[0].coords.ctype, "DEC--TAN"); 43 43 44 44 X1 = catstats[0].X; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/markstar/src/gcatstats.c
r27435 r36680 50 50 catstats[0].coords.pc1_1 = catstats[0].coords.pc2_2 = 1.0; 51 51 catstats[0].coords.pc1_2 = catstats[0].coords.pc2_1 = 0.0; 52 strcpy (catstats[0].coords.ctype, " RA---TAN");52 strcpy (catstats[0].coords.ctype, "DEC--TAN"); 53 53 54 54 X1 = catstats[0].X; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/mosastro/src/warptest.c
r3323 r36680 15 15 16 16 /* bore site center guess */ 17 sprintf (coords.ctype, " RA---%s", argv[1]);17 sprintf (coords.ctype, "DEC--%s", argv[1]); 18 18 coords.crval1 = 0.0; 19 19 coords.crval2 = 0.0; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi
- Property svn:mergeinfo deleted
-
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.astro
- Property svn:mergeinfo deleted
-
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.astro/Makefile
r35416 r36680 28 28 $(SRC)/cval.$(ARCH).o \ 29 29 $(SRC)/czplot.$(ARCH).o \ 30 $(SRC)/cdensify.$(ARCH).o \ 30 31 $(SRC)/drizzle.$(ARCH).o \ 31 32 $(SRC)/flux.$(ARCH).o \ 32 33 $(SRC)/fitplx.$(ARCH).o \ 34 $(SRC)/fitpm.$(ARCH).o \ 33 35 $(SRC)/fixwrap.$(ARCH).o \ 34 36 $(SRC)/fixcols.$(ARCH).o \ … … 60 62 $(SRC)/scale.$(ARCH).o \ 61 63 $(SRC)/sexigesimal.$(ARCH).o \ 64 $(SRC)/sersic.$(ARCH).o \ 62 65 $(SRC)/spec.$(ARCH).o \ 63 66 $(SRC)/specpairfit.$(ARCH).o \ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.astro/fitplx.c
r35416 r36680 41 41 remove_argument (N, &argc, argv); 42 42 VERBOSE = TRUE; 43 } 44 if ((N = get_argument (argc, argv, "-vv"))) { 45 remove_argument (N, &argc, argv); 46 VERBOSE = 2; 43 47 } 44 48 … … 108 112 coords.pc1_2 = coords.pc2_1 = 0.0; 109 113 coords.Npolyterms = 1; 110 strcpy (coords.ctype, " RA---SIN");114 strcpy (coords.ctype, "DEC--SIN"); 111 115 112 116 double *X, *Y, *t, *pX, *pY, *dX, *dY; … … 145 149 146 150 PlxFit fit; 147 FitPMandPar (&fit, X, dX, Y, dY, t, pX, pY, n, VERBOSE); 151 if (!FitPMandPar (&fit, X, dX, Y, dY, t, pX, pY, n, VERBOSE)) { 152 return FALSE; 153 } 148 154 149 155 // fprintf (stderr, "Roff, Doff: %f, %f; dRo, dDo: %f, %f\n", fit.Ro, fit.Do, fit.dRo, fit.dDo); … … 204 210 for (i = 0; i < Npts; i++) { 205 211 206 if (VERBOSE ) fprintf (stderr, "%f %f : %f %f : %f : %f %f\n", X[i], dX[i], Y[i], dY[i], T[i], pR[i], pD[i]);212 if (VERBOSE == 2) fprintf (stderr, "%f %f : %f %f : %f : %f %f\n", X[i], dX[i], Y[i], dY[i], T[i], pR[i], pD[i]); 207 213 208 214 /* handle case where dX or dY = 0.0 */ 209 wx = 1.0 / SQ(dX[i]);210 wy = 1.0 / SQ(dY[i]);215 wx = (fabs(dX[i]) < 0.0001) ? 1.0 : 1.0 / SQ(dX[i]); 216 wy = (fabs(dY[i]) < 0.0001) ? 1.0 : 1.0 / SQ(dY[i]); 211 217 212 218 Wx += wx; … … 266 272 B[4][0] = PRX + PDY; 267 273 268 dgaussjordan ((double **)A, (double **)B, 5, 1); 274 if (!dgaussjordan ((double **)A, (double **)B, 5, 1)) { 275 if (VERBOSE) fprintf (stderr, "error in fit\n"); 276 if (VERBOSE == 2) { 277 int j; 278 for (i = 0; i < 5; i++) { 279 for (j = 0; j < 5; j++) { 280 fprintf (stderr, "%e ", A[i][j]); 281 } 282 fprintf (stderr, " : %e\n", A[i][0]); 283 } 284 } 285 return FALSE; 286 } 269 287 270 288 fit[0].Ro = B[0][0]; … … 285 303 Xf = fit[0].Ro + fit[0].uR*T[i] + fit[0].p*pR[i]; 286 304 Yf = fit[0].Do + fit[0].uD*T[i] + fit[0].p*pD[i]; 287 chisq += SQ(X[i] - Xf) / SQ(dX[i]); 288 chisq += SQ(Y[i] - Yf) / SQ(dY[i]); 289 if (VERBOSE) fprintf (stderr, "chisq contrib : %f %f : %f %f : %f %f : %f %f : %f\n", Xf, Yf, X[i] - Xf, Y[i] - Yf, dX[i], dY[i], (X[i] - Xf) / dX[i], (Y[i] - Yf) / dY[i], chisq); 305 wx = (fabs(dX[i]) < 0.0001) ? 1.0 : 1.0 / SQ(dX[i]); 306 wy = (fabs(dY[i]) < 0.0001) ? 1.0 : 1.0 / SQ(dY[i]); 307 chisq += SQ(X[i] - Xf) * wx; 308 chisq += SQ(Y[i] - Yf) * wy; 309 // if (VERBOSE) fprintf (stderr, "chisq contrib : %f %f : %f %f : %f %f : %f %f : %f\n", Xf, Yf, X[i] - Xf, Y[i] - Yf, dX[i], dY[i], (X[i] - Xf) / dX[i], (Y[i] - Yf) / dY[i], chisq); 290 310 } 291 311 fit[0].Nfit = Npts; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.astro/gauss.c
r34088 r36680 10 10 Buffer *buf; 11 11 KapaImageData data; 12 int VERBOSE; 13 14 VERBOSE = TRUE; 15 if ((N = get_argument (argc, argv, "-q"))) { 16 VERBOSE = FALSE; 17 remove_argument (N, &argc, argv); 18 } 19 if ((N = get_argument (argc, argv, "-quiet"))) { 20 VERBOSE = FALSE; 21 remove_argument (N, &argc, argv); 22 } 12 23 13 24 name = NULL; … … 58 69 KiiCursorRead (kapa, &X, &Y, &ZP, &RA, &DEC, key); 59 70 if (!strcasecmp (key, "Q")) break; 60 get_aperture_stats (&buf[0].matrix, (int)(X+0.5), (int)(Y+0.5), Npix, Nborder, max );71 get_aperture_stats (&buf[0].matrix, (int)(X+0.5), (int)(Y+0.5), Npix, Nborder, max, VERBOSE); 61 72 } 62 73 KiiCursorOff (kapa); … … 64 75 } 65 76 77 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.astro/init.c
r35757 r36680 13 13 int czplot PROTO((int, char **)); 14 14 int czcplot PROTO((int, char **)); 15 int cdensify PROTO((int, char **)); 15 16 int drizzle PROTO((int, char **)); 16 17 int flux PROTO((int, char **)); 17 18 int fitplx PROTO((int, char **)); 19 int fitpm PROTO((int, char **)); 18 20 int fixwrap PROTO((int, char **)); 19 21 int fiximage PROTO((int, char **)); … … 49 51 int scale PROTO((int, char **)); 50 52 int sexigesimal PROTO((int, char **)); 53 int sersic PROTO((int, char **)); 51 54 int spec PROTO((int, char **)); 52 55 int specpairfit PROTO((int, char **)); … … 72 75 {1, "czplot", czplot, "plot scaled vectors in sky coordinates"}, 73 76 {1, "czcplot", czcplot, "plot color-scaled vectors in sky coordinates"}, 77 {1, "cdensify", cdensify, "vectors to density history on projection"}, 74 78 {1, "drizzle", drizzle, "transform image to image"}, 75 79 {1, "flux", flux, "flux in a convex contour"}, 76 80 {1, "fitplx", fitplx, "fit proper motion and parallax"}, 81 {1, "fitpm", fitpm, "fit proper motion only"}, 77 82 {1, "fixwrap", fixwrap, "fix megacam over-wrapped pixels"}, 78 83 {1, "fiximage", fiximage, "fix pixels in an image by interpolation"}, … … 107 112 {1, "scale", scale, "get / set real bzero / bscale values"}, 108 113 {1, "sexigesimal", sexigesimal, "convert to/from sexigesimal/decimal"}, 114 {1, "sersic", sersic, "generate sub-pixel resolved sersic model"}, 109 115 {1, "spec", spec, "extract a spectrum"}, 110 116 {1, "specpairfit", specpairfit, "fit spectrum to another spectrum"}, -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.astro/region.c
r31160 r36680 80 80 if (!ohana_str_to_radec (&Ra, &Dec, argv[1], argv[2])) return (FALSE); 81 81 Radius = atof (argv[3]); 82 strcpy (graphmode.coords.ctype, " RA---TAN");82 strcpy (graphmode.coords.ctype, "DEC--TAN"); 83 83 if (argc == 5) { 84 84 if (!strcasecmp (argv[4], "TAN")) 85 strcpy (graphmode.coords.ctype, " RA---TAN");85 strcpy (graphmode.coords.ctype, "DEC--TAN"); 86 86 if (!strcasecmp (argv[4], "SIN")) 87 strcpy (graphmode.coords.ctype, " RA---SIN");87 strcpy (graphmode.coords.ctype, "DEC--SIN"); 88 88 if (!strcasecmp (argv[4], "ARC")) 89 strcpy (graphmode.coords.ctype, " RA---ARC");89 strcpy (graphmode.coords.ctype, "DEC--ARC"); 90 90 if (!strcasecmp (argv[4], "STG")) 91 strcpy (graphmode.coords.ctype, " RA---STG");91 strcpy (graphmode.coords.ctype, "DEC--STG"); 92 92 if (!strcasecmp (argv[4], "ZEA")) 93 strcpy (graphmode.coords.ctype, " RA---ZEA");93 strcpy (graphmode.coords.ctype, "DEC--ZEA"); 94 94 if (!strcasecmp (argv[4], "AIT")) 95 strcpy (graphmode.coords.ctype, " RA---AIT");95 strcpy (graphmode.coords.ctype, "DEC--AIT"); 96 96 if (!strcasecmp (argv[4], "GLS")) 97 strcpy (graphmode.coords.ctype, " RA---GLS");97 strcpy (graphmode.coords.ctype, "DEC--GLS"); 98 98 if (!strcasecmp (argv[4], "PAR")) 99 strcpy (graphmode.coords.ctype, " RA---PAR");99 strcpy (graphmode.coords.ctype, "DEC--PAR"); 100 100 } 101 101 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.astro/star.c
r34088 r36680 6 6 double max; 7 7 Buffer *buf; 8 int VERBOSE; 9 10 VERBOSE = TRUE; 11 if ((N = get_argument (argc, argv, "-q"))) { 12 VERBOSE = FALSE; 13 remove_argument (N, &argc, argv); 14 } 15 if ((N = get_argument (argc, argv, "-quiet"))) { 16 VERBOSE = FALSE; 17 remove_argument (N, &argc, argv); 18 } 8 19 9 20 Nborder = 3; … … 36 47 } 37 48 38 get_aperture_stats (&buf[0].matrix, x, y, dx, Nborder, max );49 get_aperture_stats (&buf[0].matrix, x, y, dx, Nborder, max, VERBOSE); 39 50 40 51 return (TRUE); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.basic/list.c
r33662 r36680 2 2 # define D_NLINES 100 3 3 static char prompt[] = ">> "; 4 5 static int set_list_varname (char *line, char *base, int N, int excelStyle); 4 6 5 7 int list (int argc, char **argv) { … … 21 23 } 22 24 25 int EXCEL_STYLE = FALSE; 26 if ((N = get_argument (argc, argv, "-excel-style"))) { 27 remove_argument (N, &argc, argv); 28 EXCEL_STYLE = TRUE; 29 } 30 if ((N = get_argument (argc, argv, "-excel"))) { 31 remove_argument (N, &argc, argv); 32 EXCEL_STYLE = TRUE; 33 } 34 23 35 if ((N = get_argument (argc, argv, "-vectors"))) { 24 36 remove_argument (N, &argc, argv); … … 49 61 50 62 for (i = 0; i < argc - 3; i++) { 51 s printf (line, "%s:%d", argv[1], i);63 set_list_varname (line, argv[1], i, EXCEL_STYLE); 52 64 set_str_variable (line, argv[i+3]); 53 65 } … … 83 95 if (!word) break; 84 96 85 sprintf (line, "%s:%d", argv[1], nWords); 97 // sprintf (line, "%s:%d", argv[1], nWords); 98 set_list_varname (line, argv[1], nWords, EXCEL_STYLE); 99 86 100 set_str_variable (line, word); 87 101 FREE (word); … … 120 134 sprintf (line, "%s:%d", argv[3], i); 121 135 value = get_variable (line); 122 sprintf (line, "%s:%d", argv[1], i); 136 // sprintf (line, "%s:%d", argv[1], i); 137 set_list_varname (line, argv[1], i, EXCEL_STYLE); 123 138 set_str_variable (line, value); 124 139 } … … 136 151 N = get_int_variable (line, &found); 137 152 for (i = 0; i < argc - 3; i++) { 138 sprintf (line, "%s:%d", argv[1], N + i); 153 // sprintf (line, "%s:%d", argv[1], N + i); 154 set_list_varname (line, argv[1], N + i, EXCEL_STYLE); 139 155 set_str_variable (line, argv[i+3]); 140 156 } … … 159 175 N = get_int_variable (line, &found); 160 176 for (i = 0; i < N; i++) { 161 sprintf (line, "%s:%d", argv[1], i); 177 // sprintf (line, "%s:%d", argv[1], i); 178 set_list_varname (line, argv[1], i, EXCEL_STYLE); 162 179 value = get_variable (line); 163 180 if (value == NULL) continue; … … 165 182 free (value); 166 183 for (j = i + 1; j < N; j++) { 167 sprintf (line2, "%s:%d", argv[1], j); 184 // sprintf (line2, "%s:%d", argv[1], j); 185 set_list_varname (line2, argv[1], j, EXCEL_STYLE); 168 186 next_value = get_variable (line2); 169 187 set_str_variable (line, next_value); … … 235 253 if (B != (char *) NULL) { *B = 0; } 236 254 if (*A != 0) { 237 sprintf (line, "%s:%d", argv[1], i); 255 // sprintf (line, "%s:%d", argv[1], i); 256 set_list_varname (line, argv[1], i, EXCEL_STYLE); 238 257 set_str_variable (line, A); 239 258 A = B + 1; … … 283 302 284 303 if (*input) { 285 sprintf (line, "%s:%d", argv[1], i); 304 // sprintf (line, "%s:%d", argv[1], i); 305 set_list_varname (line, argv[1], i, EXCEL_STYLE); 286 306 set_str_variable (line, input); 287 307 free (input); 288 308 i++; 289 }309 } 290 310 } 291 311 return (TRUE); 292 312 } 313 314 static int set_list_varname (char *line, char *base, int N, int excelStyle) { 315 316 int i; 317 318 // A-Z correspond to 0 - 25 319 320 if (excelStyle) { 321 float f = log(26.0); 322 float g = (N == 0) ? 0.0 : log(1.0*N); 323 int Ndigit = (int) (g / f) + 1; 324 if (Ndigit > 10) { 325 sprintf (line, "%s:ZZZZZZZZZZ", base); 326 return FALSE; 327 } 328 char name[12]; 329 memset (name, 0, 12); 330 for (i = 0; i < Ndigit; i++) { 331 float Npow = Ndigit - i - 1; 332 float g = pow(26.0, Npow); 333 int V = (int) (N / g); 334 name[i] = (Npow == 0.0) ? 'A' + V : 'A' + V - 1; 335 N -= V * g; 336 } 337 sprintf (line, "%s:%s", base, name); 338 } else { 339 sprintf (line, "%s:%d", base, N); 340 } 341 return TRUE; 342 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.data
- Property svn:mergeinfo deleted
-
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.data/Makefile
r35416 r36680 25 25 $(SRC)/book.$(ARCH).o \ 26 26 $(SRC)/book_commands.$(ARCH).o \ 27 $(SRC)/cast.$(ARCH).o \ 27 28 $(SRC)/center.$(ARCH).o \ 28 29 $(SRC)/clear.$(ARCH).o \ … … 63 64 $(SRC)/imcut.$(ARCH).o \ 64 65 $(SRC)/imhist.$(ARCH).o \ 66 $(SRC)/impeaks.$(ARCH).o \ 65 67 $(SRC)/imsmooth.$(ARCH).o \ 68 $(SRC)/imsmooth.generic.$(ARCH).o \ 69 $(SRC)/imsmooth.2d.$(ARCH).o \ 66 70 $(SRC)/integrate.$(ARCH).o \ 67 71 $(SRC)/interpolate.$(ARCH).o \ 72 $(SRC)/join.$(ARCH).o \ 68 73 $(SRC)/jpeg.$(ARCH).o \ 69 74 $(SRC)/kern.$(ARCH).o \ … … 84 89 $(SRC)/mget.$(ARCH).o \ 85 90 $(SRC)/minterpolate.$(ARCH).o \ 91 $(SRC)/medimage.$(ARCH).o \ 92 $(SRC)/medimage_commands.$(ARCH).o \ 86 93 $(SRC)/mset.$(ARCH).o \ 87 94 $(SRC)/peak.$(ARCH).o \ … … 143 150 $(SRC)/vmaxwell.$(ARCH).o \ 144 151 $(SRC)/vgrid.$(ARCH).o \ 152 $(SRC)/vlist.$(ARCH).o \ 145 153 $(SRC)/vload.$(ARCH).o \ 146 154 $(SRC)/vzload.$(ARCH).o \ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.data/densify.c
r34088 r36680 2 2 3 3 # define CHECKVAL(ARG) if (!isfinite(ARG)) { gprint (GP_ERR, "illegal value for %s: %f\n", #ARG, ARG); return (FALSE); } 4 enum {IS_DOT, IS_SQUARE, IS_CIRCLE, IS_GAUSS}; 4 5 5 6 int densify (int argc, char **argv) { 6 7 7 int i, Nx, Ny, Xb, Yb, N, Xpix, Ypix, good, UseGraph;8 int i, Nx, Ny, Xb, Yb, ix, iy, N, Xpix, Ypix, good, UseGraph; 8 9 double Xmin, Xmax, dX, Ymin, Ymax, dY; 9 10 float *val; … … 24 25 } 25 26 27 float scale = 0.0; 28 if ((N = get_argument (argc, argv, "-scale"))) { 29 remove_argument (N, &argc, argv); 30 scale = atof(argv[N]); 31 remove_argument (N, &argc, argv); 32 } 33 34 int PSFTYPE = IS_DOT; 35 if ((N = get_argument (argc, argv, "-psf"))) { 36 remove_argument (N, &argc, argv); 37 if (!strcasecmp(argv[N], "dot")) PSFTYPE = IS_DOT; 38 if (!strcasecmp(argv[N], "square")) PSFTYPE = IS_SQUARE; 39 if (!strcasecmp(argv[N], "circle")) PSFTYPE = IS_CIRCLE; 40 if (!strcasecmp(argv[N], "gauss")) PSFTYPE = IS_GAUSS; 41 remove_argument (N, &argc, argv); 42 } 43 26 44 good = UseGraph ? (argc == 4) : (argc == 10); 27 45 if (!good) { 28 46 gprint (GP_ERR, "USAGE: densify buffer x y Xmin Xmax dX Ymin Ymax dY\n"); 29 47 gprint (GP_ERR, " OR: densify buffer x y -graph\n"); 48 gprint (GP_ERR, " option: -psf [dot] (circle) (square) (gauss)\n"); 30 49 return (FALSE); 31 50 } … … 69 88 CHECKVAL(dY); 70 89 90 float scaleX = (scale > 0.0) ? scale / dX : 3.0; 91 float scaleY = (scale > 0.0) ? scale / dY : 3.0; 92 71 93 Nx = (Xmax - Xmin) / dX + 1; 72 94 Ny = (Ymax - Ymin) / dY + 1; … … 76 98 CreateBuffer (bf, Nx, Ny, -32, 0.0, 1.0); 77 99 strcpy (bf[0].file, "(empty)"); 100 101 float scale2 = (scaleX + 1.0) * (scaleY + 1.0); 102 float fSquare = 1.0 / scale2; 103 float fCircle = 1.0 / (3.141592 * scale2); 104 float fSigma = 0.5 / scale2; 105 float fGauss = 1.0 / (2.0 * 3.141592 * scale2); 78 106 79 107 x = vx[0].elements.Flt; … … 83 111 Xb = (*x - Xmin) / dX; 84 112 Yb = (*y - Ymin) / dY; 85 if (Xb >= Nx) continue; 86 if (Yb >= Ny) continue; 87 if (Xb < 0) continue; 88 if (Yb < 0) continue; 89 val[Xb + Yb*Nx] ++; 113 switch (PSFTYPE) { 114 case IS_DOT: 115 if (Xb >= Nx) continue; 116 if (Yb >= Ny) continue; 117 if (Xb < 0) continue; 118 if (Yb < 0) continue; 119 val[Xb + Yb*Nx] ++; 120 break; 121 case IS_SQUARE: 122 for (ix = Xb - scaleX; ix <= Xb + scaleX; ix++) { 123 for (iy = Yb - scaleY; iy <= Yb + scaleY; iy++) { 124 if (ix >= Nx) continue; 125 if (iy >= Ny) continue; 126 if (ix < 0) continue; 127 if (iy < 0) continue; 128 val[ix + iy*Nx] += fSquare; 129 } 130 } 131 break; 132 case IS_CIRCLE: 133 for (ix = Xb - scaleX; ix <= Xb + scaleX; ix++) { 134 float dX = ix - Xb; 135 for (iy = Yb - scaleY; iy <= Yb + scaleY; iy++) { 136 float dY = iy - Yb; 137 float r2 = dX*dX + dY*dY; 138 if (r2 > 9) continue; 139 if (ix >= Nx) continue; 140 if (iy >= Ny) continue; 141 if (ix < 0) continue; 142 if (iy < 0) continue; 143 val[ix + iy*Nx] += fCircle; 144 } 145 } 146 break; 147 case IS_GAUSS: 148 for (ix = Xb - scaleX; ix <= Xb + scaleX; ix++) { 149 float dX = ix - Xb; 150 for (iy = Yb - scaleY; iy <= Yb + scaleY; iy++) { 151 float dY = iy - Yb; 152 float r2 = dX*dX + dY*dY; 153 if (ix >= Nx) continue; 154 if (iy >= Ny) continue; 155 if (ix < 0) continue; 156 if (iy < 0) continue; 157 val[ix + iy*Nx] += fGauss*exp(-fSigma*r2); 158 } 159 } 160 break; 161 } 90 162 } 91 163 return (TRUE); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.data/init.c
r35416 r36680 10 10 int center PROTO((int, char **)); 11 11 int parity PROTO((int, char **)); 12 int cast PROTO((int, char **)); 12 13 int circstats PROTO((int, char **)); 13 14 int clear PROTO((int, char **)); … … 52 53 int imcut PROTO((int, char **)); 53 54 int imhist PROTO((int, char **)); 55 int impeaks PROTO((int, char **)); 54 56 int imsmooth PROTO((int, char **)); 57 int imsmooth_generic PROTO((int, char **)); 58 int imsmooth_2d PROTO((int, char **)); 55 59 int integrate PROTO((int, char **)); 56 60 int interpolate PROTO((int, char **)); 61 int join PROTO((int, char **)); 57 62 int jpeg PROTO((int, char **)); 58 63 int kern PROTO((int, char **)); … … 74 79 int mget PROTO((int, char **)); 75 80 int minterp PROTO((int, char **)); 81 int medimage_command PROTO((int, char **)); 76 82 int mset PROTO((int, char **)); 77 83 int peak PROTO((int, char **)); … … 133 139 int vmaxwell PROTO((int, char **)); 134 140 int vload PROTO((int, char **)); 141 int vlist PROTO((int, char **)); 135 142 int vzload PROTO((int, char **)); 136 143 int vstats PROTO((int, char **)); … … 160 167 {1, "buffers", list_buffers, "list the currently allocated buffers (images)"}, 161 168 {1, "center", center, "center image on coords"}, 169 {1, "cast", cast, "cast input vector to specified type"}, 162 170 {1, "circstats", circstats, "circular statistics"}, 163 171 {1, "clear", clear, "erase plot"}, … … 205 213 {1, "imcut", imcut, "linear image cut between arbitrary coords"}, 206 214 {1, "imhistogram", imhist, "histogram of an image region"}, 215 {1, "impeaks", impeaks, "find peaks in an image (return vectors)"}, 207 216 {1, "imsmooth", imsmooth, "circular gaussian smoothing"}, 217 {1, "imsmooth.generic", imsmooth_generic, "circular non-gaussian smoothing"}, 218 {1, "imsmooth.2d", imsmooth_2d, "circular non-gaussian smoothing"}, 208 219 {1, "imstats", imstats, "statistics on a portion of an image"}, 209 220 {1, "integrate", integrate, "integrate a vector"}, 210 221 {1, "interpolate", interpolate, "interpolate between vector pairs"}, 222 {1, "join", join, "find the join of two ID vectors"}, 211 223 {1, "jpeg", jpeg, "convert display image to JPEG"}, 212 224 {1, "kern", kern, "convolve with 3x3 kernel"}, … … 224 236 {1, "minterp", minterp, "interpolate image pixels"}, 225 237 {1, "iminterp", minterp, "interpolate image pixels"}, 238 {1, "medimage", medimage_command, "median image manipulation"}, 226 239 {1, "matrix", matrix, "matrix math operations"}, 227 240 {1, "match2d", match2d, "match 2 pairs of X,Y vectors and return matched indexes"}, … … 290 303 {1, "vgrid", vgrid, "generate an image from a triplet of vectors"}, 291 304 {1, "vhistogram", histogram, "generate histogram from vector"}, 305 {1, "vlist", vlist, "append values to a vector from command line"}, 292 306 {1, "vload", vload, "load vectors as overlay on image display"}, 293 307 {1, "vmaxwell", vmaxwell, "fit a Maxwellian to a vector"}, -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.data/match2d.c
r33963 r36680 14 14 Vector *index1, *index2; 15 15 16 if ((N = get_argument (argc, argv, "-h"))) goto usage; 17 if ((N = get_argument (argc, argv, "--help"))) goto usage; 18 16 19 CLOSEST = FALSE; 17 20 if ((N = get_argument (argc, argv, "-closest"))) { … … 38 41 if (argc != 6) { 39 42 gprint (GP_ERR, "USAGE: match2d X1 Y1 X2 Y2 Radius [-index1 (index1)] [-index2 (index2)] [-closest]\n"); 40 gprint (GP_ERR, " if -closest is provided, index1 & index2 will have the same length as X1 and X2 (respectively)\n"); 41 gprint (GP_ERR, " with either the index of the match or a value of -1 for non-matches\n"); 43 gprint (GP_ERR, " use -h or --help for more detail\n"); 42 44 return (FALSE); 43 45 } … … 90 92 91 93 return (TRUE); 94 95 usage: 96 gprint (GP_ERR, "we have two modes of operation:\n\n"); 97 98 gprint (GP_ERR, "without -closest, we are finding all matched pairs within the match radius. in this\n"); 99 gprint (GP_ERR, "case, the two index vectors have the same length, one entry per matched pair.\n"); 100 gprint (GP_ERR, "x1[index1],y1[index1] matches to x2[index2],y2[index2].\n\n"); 101 102 gprint (GP_ERR, "with -closest selected, we are finding the closest element of set 1 to each of set 2\n"); 103 gprint (GP_ERR, "and vice versa. in this case, index1 is always the same length as x1,y1, while index2\n"); 104 gprint (GP_ERR, "is the same lengths as x2,y2. x2[index1],y2[index1] matches x1,y1 while\n"); 105 gprint (GP_ERR, "x1[index2],y1[index2] matches x2,y2\n\n"); 106 107 gprint (GP_ERR, "if -index1 or -index2 is not supplied, the vectors are created with names index1 or index2\n"); 108 gprint (GP_ERR, "use 'reindex' to generate new vectors based on these index vectors\n"); 109 110 return FALSE; 92 111 } 93 112 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.data/read_vectors.c
r34753 r36680 23 23 // vector types 24 24 enum {COLTYPE_NONE, COLTYPE_FLT, COLTYPE_INT, COLTYPE_TIME, COLTYPE_CHAR}; 25 static int FITS_TRANSPOSE; 25 26 26 27 int read_vectors (int argc, char **argv) { … … 34 35 35 36 char *buffer = NULL; 37 38 FITS_TRANSPOSE = FALSE; 39 if ((Narg = get_argument (argc, argv, "-transpose"))) { 40 remove_argument (Narg, &argc, argv); 41 FITS_TRANSPOSE = TRUE; 42 } 36 43 37 44 /* auto-sense table type */ … … 410 417 } 411 418 412 // define the multifield vector names 413 ALLOCATE (vec, Vector *, Nval); 414 for (j = 0; j < Nval; j++) { 415 if (Nval == 1) 416 sprintf (name, "%s", argv[i]); 417 else 418 sprintf (name, "%s:%d", argv[i], j); 419 if ((vec[j] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) ESCAPE ("bad vector name"); 420 ResetVector (vec[j], vecType, Ny); 421 } 422 423 if (!strcmp (type, "char")) { 424 char *Ptr = data; 419 if (!FITS_TRANSPOSE) { 420 // define the multifield vector names (Nval vectors x Ny elements) 421 ALLOCATE (vec, Vector *, Nval); 422 for (j = 0; j < Nval; j++) { 423 if (Nval == 1) 424 sprintf (name, "%s", argv[i]); 425 else 426 sprintf (name, "%s:%d", argv[i], j); 427 if ((vec[j] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) ESCAPE ("bad vector name"); 428 ResetVector (vec[j], vecType, Ny); 429 } 430 431 if (!strcmp (type, "char")) { 432 char *Ptr = data; 433 for (j = 0; j < Ny; j++) { 434 for (k = 0; k < Nval; k++, Ptr++) { 435 vec[k][0].elements.Int[j] = *Ptr; 436 } 437 } 438 } 439 if (!strcmp (type, "short")) { 440 short *Ptr = data; 441 for (j = 0; j < Ny; j++) { 442 for (k = 0; k < Nval; k++, Ptr++) { 443 vec[k][0].elements.Int[j] = *Ptr; 444 } 445 } 446 } 447 if (!strcmp (type, "int")) { 448 int *Ptr = data; 449 for (j = 0; j < Ny; j++) { 450 for (k = 0; k < Nval; k++, Ptr++) { 451 vec[k][0].elements.Int[j] = *Ptr; 452 } 453 } 454 } 455 if (!strcmp (type, "int64_t")) { 456 int64_t *Ptr = data; 457 for (j = 0; j < Ny; j++) { 458 for (k = 0; k < Nval; k++, Ptr++) { 459 vec[k][0].elements.Int[j] = *Ptr; 460 } 461 } 462 } 463 if (!strcmp (type, "float")) { 464 float *Ptr = data; 465 for (j = 0; j < Ny; j++) { 466 for (k = 0; k < Nval; k++, Ptr++) { 467 vec[k][0].elements.Flt[j] = *Ptr; 468 } 469 } 470 } 471 if (!strcmp (type, "double")) { 472 double *Ptr = data; 473 for (j = 0; j < Ny; j++) { 474 for (k = 0; k < Nval; k++, Ptr++) { 475 vec[k][0].elements.Flt[j] = *Ptr; 476 } 477 } 478 } 479 } else { 480 // define the multifield vector names (Ny vectors x Nval elements) 481 ALLOCATE (vec, Vector *, Ny); 425 482 for (j = 0; j < Ny; j++) { 426 for (k = 0; k < Nval; k++, Ptr++) { 427 vec[k][0].elements.Int[j] = *Ptr; 428 } 429 } 430 } 431 if (!strcmp (type, "short")) { 432 short *Ptr = data; 433 for (j = 0; j < Ny; j++) { 434 for (k = 0; k < Nval; k++, Ptr++) { 435 vec[k][0].elements.Int[j] = *Ptr; 436 } 437 } 438 } 439 if (!strcmp (type, "int")) { 440 int *Ptr = data; 441 for (j = 0; j < Ny; j++) { 442 for (k = 0; k < Nval; k++, Ptr++) { 443 vec[k][0].elements.Int[j] = *Ptr; 444 } 445 } 446 } 447 if (!strcmp (type, "int64_t")) { 448 int64_t *Ptr = data; 449 for (j = 0; j < Ny; j++) { 450 for (k = 0; k < Nval; k++, Ptr++) { 451 vec[k][0].elements.Int[j] = *Ptr; 452 } 453 } 454 } 455 if (!strcmp (type, "float")) { 456 float *Ptr = data; 457 for (j = 0; j < Ny; j++) { 458 for (k = 0; k < Nval; k++, Ptr++) { 459 vec[k][0].elements.Flt[j] = *Ptr; 460 } 461 } 462 } 463 if (!strcmp (type, "double")) { 464 double *Ptr = data; 465 for (j = 0; j < Ny; j++) { 466 for (k = 0; k < Nval; k++, Ptr++) { 467 vec[k][0].elements.Flt[j] = *Ptr; 483 if (Ny == 1) 484 sprintf (name, "%s", argv[i]); 485 else 486 sprintf (name, "%s:%d", argv[i], j); 487 if ((vec[j] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) ESCAPE ("bad vector name"); 488 ResetVector (vec[j], vecType, Nval); 489 } 490 491 if (!strcmp (type, "char")) { 492 char *Ptr = data; 493 for (j = 0; j < Ny; j++) { 494 for (k = 0; k < Nval; k++, Ptr++) { 495 vec[j][0].elements.Int[k] = *Ptr; 496 } 497 } 498 } 499 if (!strcmp (type, "short")) { 500 short *Ptr = data; 501 for (j = 0; j < Ny; j++) { 502 for (k = 0; k < Nval; k++, Ptr++) { 503 vec[j][0].elements.Int[k] = *Ptr; 504 } 505 } 506 } 507 if (!strcmp (type, "int")) { 508 int *Ptr = data; 509 for (j = 0; j < Ny; j++) { 510 for (k = 0; k < Nval; k++, Ptr++) { 511 vec[j][0].elements.Int[k] = *Ptr; 512 } 513 } 514 } 515 if (!strcmp (type, "int64_t")) { 516 int64_t *Ptr = data; 517 for (j = 0; j < Ny; j++) { 518 for (k = 0; k < Nval; k++, Ptr++) { 519 vec[j][0].elements.Int[k] = *Ptr; 520 } 521 } 522 } 523 if (!strcmp (type, "float")) { 524 float *Ptr = data; 525 for (j = 0; j < Ny; j++) { 526 for (k = 0; k < Nval; k++, Ptr++) { 527 vec[j][0].elements.Flt[k] = *Ptr; 528 } 529 } 530 } 531 if (!strcmp (type, "double")) { 532 double *Ptr = data; 533 for (j = 0; j < Ny; j++) { 534 for (k = 0; k < Nval; k++, Ptr++) { 535 vec[j][0].elements.Flt[k] = *Ptr; 536 } 468 537 } 469 538 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.data/rebin.c
r28241 r36680 133 133 *Vout += *Vin; 134 134 if (Normalize) {(*Vn) ++;} 135 // if ((i == 1) && (j == 1)) fprintf (stderr, "%d,%d : %d,%d : %f : %f : %d\n", i, j, x, y, *Vin, *Vout, *Vn); 135 136 } 136 137 if (Normalize) {Vn ++;} -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.data/vellipse.c
r25757 r36680 228 228 */ 229 229 230 // XXX NOTE that PHI is defined with the wrong sign, should fix this... 230 231 opihi_flt fellipseOD (opihi_flt alpha, opihi_flt *par, int Npar, opihi_flt *dpar) { 231 232 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/cmd.data/vgauss.c
r35109 r36680 48 48 if ((ovec = SelectVector (argv[4], ANYVECTOR, TRUE)) == NULL) return (FALSE); 49 49 50 CastVector (xvec, OPIHI_FLT); 51 CastVector (yvec, OPIHI_FLT); 52 50 53 int Nsvec = strlen(argv[3]); 51 54 … … 69 72 } 70 73 71 CastVector (xvec, OPIHI_FLT);72 CastVector (yvec, OPIHI_FLT);73 74 CastVector (svec, OPIHI_FLT); 74 75 // XXX Cast is failing. -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/dvo/Makefile
r34461 r36680 40 40 $(SRC)/cmpload.$(ARCH).o \ 41 41 $(SRC)/cmpread.$(ARCH).o \ 42 $(SRC)/coordimage.$(ARCH).o \ 42 43 $(SRC)/ddmags.$(ARCH).o \ 43 44 $(SRC)/detrend.$(ARCH).o \ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/dvo/avmatch.c
r35416 r36680 70 70 dbExtractAveragesInit (); 71 71 72 // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results73 72 RAvec = NULL; 74 73 DECvec = NULL; 75 if (PARALLEL && !HOST_ID) {76 if (!CoordsFile) {77 // get vectors corresponding to coordinates of interest78 if ((RAvec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto help;79 if ((DECvec = SelectVector (argv[2], ANYVECTOR, TRUE)) == NULL) goto help;80 81 ALLOCATE (vec, Vector *, 2);82 vec[0] = RAvec;83 vec[1] = DECvec;84 85 CoordsFile = abspath("coords.fits", 1024);86 int status = WriteVectorTableFITS (CoordsFile, "COORDS", vec, 2, FALSE, NULL);87 if (!status) goto escape;88 }89 90 char *targv1 = argv[1];91 char *targv2 = argv[2];92 argv[1] = strcreate ("-coords");93 argv[2] = strcreate (CoordsFile);94 free (CoordsFile);95 96 // I need to pass the RA & DEC vectors to the remote clients...97 int status = HostTableParallelOps (skylist, argc, argv, RESULT_FILE, TRUE, RAvec->Nelements, VERBOSE);98 if (vec) free (vec);99 100 free (argv[1]);101 free (argv[2]);102 argv[1] = targv1;103 argv[2] = targv2;104 105 return status;106 }107 108 74 // get vectors corresponding to coordinates of interest 109 75 if (CoordsFile) { … … 120 86 remove_argument (1, &argc, argv); 121 87 } 88 89 /* load regions which contain all supplied RA,DEC coordinates */ 90 if ((skylist = SelectRegionsByCoordVectors (RAvec, DECvec)) == NULL) goto escape; 91 92 // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results 93 if (PARALLEL && !HOST_ID) { 94 95 // We need to copy the args to a temp array and modify them so that we send the 96 // correct set to the remote client. The args list looks like this: 97 // if (!CoordsFile) : avmatch (RADIUS) field, ... [we removed RA & DEC above] 98 // if ( CoordsFile) : avmatch (RADIUS) field, ... [because we stripped off the -coords filename elements] 99 100 // allocate the temp array and copy all but (RA) (DEC) 101 int targc = 0; 102 char **targv = NULL; 103 ALLOCATE (targv, char *, argc + 2); 104 for (i = 0; i < argc; i++) { 105 targv[targc] = strcreate (argv[i]); 106 targc ++; 107 } 108 109 // if not specified, create the coords.fits input file 110 // NOTE: RAvec, DECvec were set above 111 if (!CoordsFile) { 112 ALLOCATE (vec, Vector *, 2); 113 vec[0] = RAvec; 114 vec[1] = DECvec; 115 116 CoordsFile = abspath("coords.fits", 1024); 117 int status = WriteVectorTableFITS (CoordsFile, "COORDS", vec, 2, FALSE, NULL); 118 if (!status) goto escape; 119 } 120 121 // add the coords file to the args list 122 targv[targc+0] = strcreate ("-coords"); 123 targv[targc+1] = CoordsFile; // this gets freed with targv 124 targc += 2; 125 126 // I need to pass the RA & DEC vectors to the remote clients... 127 int status = HostTableParallelOps (skylist, targc, targv, RESULT_FILE, TRUE, RAvec->Nelements, VERBOSE); 128 if (vec) free (vec); 129 130 // free up targv 131 for (i = 0; i < targc; i++) { 132 free (targv[i]); 133 } 134 free (targv); 135 136 return status; 137 } 138 122 139 RADIUS = atof (argv[1]); 123 140 remove_argument (1, &argc, argv); … … 140 157 if (fields[i].photcode[0].type == PHOT_DEP) needMeasures = TRUE; 141 158 } 142 143 /* load regions which contain all supplied RA,DEC coordinates */144 if ((skylist = SelectRegionsByCoordVectors (RAvec, DECvec)) == NULL) goto escape;145 159 146 160 /* create output storage vectors */ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/dvo/dvo_client.c
r35263 r36680 90 90 } 91 91 92 // these are set in 'startup.c' for readline-based programs 93 set_variable ("PID", getpid()); 94 set_str_variable ("KAPA", "kapa"); 95 set_int_variable ("UNSIGN", 0); 96 gfits_set_unsign_mode (FALSE); 97 92 98 return; 93 99 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/dvo/find_matches.c
r29759 r36680 50 50 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 51 51 tcoords.Npolyterms = 1; 52 strcpy (tcoords.ctype, " RA---ARC");52 strcpy (tcoords.ctype, "DEC--ARC"); 53 53 54 54 // this region includes a boundary layer of size RADIUS -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/dvo/gimages.c
r34844 r36680 136 136 local.pc2_1 = local.pc1_2 = 0.0; 137 137 local.Npolyterms = 1; 138 strcpy (local.ctype, " RA---TAN");138 strcpy (local.ctype, "DEC--TAN"); 139 139 140 140 if (typehash == DistortImage) { -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/dvo/hosts.c
r35757 r36680 12 12 gprint (GP_ERR, " commands:\n"); 13 13 gprint (GP_ERR, " purge-temp : delete all tempfiles for this shell\n"); 14 gprint (GP_ERR, " : [-old-pid] [-all-pid] [-v] [-verbose] [-commit] [-type type] \n");14 gprint (GP_ERR, " : [-old-pid] [-all-pid] [-v] [-verbose] [-commit] [-type type] [-age hours]\n"); 15 15 gprint (GP_ERR, " get-results : determine name of RESULTS file\n"); 16 16 return FALSE; … … 33 33 } 34 34 35 struct timeval now; 36 gettimeofday (&now, NULL); 37 38 float AGE = 0; 39 int NOW = now.tv_sec; 40 if ((N = get_argument (argc, argv, "-age"))) { 41 remove_argument (N, &argc, argv); 42 AGE = atof(argv[N]); 43 remove_argument (N, &argc, argv); 44 } 45 35 46 int VERBOSE = FALSE; 36 47 if ((N = get_argument (argc, argv, "-v"))) { … … 121 132 glob (name, 0, NULL, &pglob); 122 133 int j; 134 struct stat filestats; 123 135 for (j = 0; j < pglob.gl_pathc; j++) { 136 if (AGE > 0) { 137 if (stat(pglob.gl_pathv[j], &filestats)) { 138 gprint (GP_ERR, "failed to get stats for %s\n", pglob.gl_pathv[j]); 139 continue; 140 } 141 float myAge = (NOW - filestats.st_mtime) / 3600.0; 142 if (myAge < AGE) continue; 143 } 124 144 if (VERBOSE) gprint (GP_ERR, "unlink %s\n", pglob.gl_pathv[j]); 125 145 if (!DRYRUN) unlink (pglob.gl_pathv[j]); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/dvo/init.c
r34461 r36680 13 13 int cmpload PROTO((int, char **)); 14 14 int cmpread PROTO((int, char **)); 15 int coordimage PROTO((int, char **)); 15 16 int ddmags PROTO((int, char **)); 16 17 int detrend PROTO((int, char **)); … … 71 72 {1, "cmpload", cmpload, "load cmp file into ?"}, 72 73 {1, "cmpread", cmpread, "read data from cmp format files"}, 74 {1, "coordimage", coordimage, "generate a map of the transformation residuals"}, 73 75 {1, "ddmags", ddmags, "plot magnitude differences"}, 74 76 {1, "detrend", detrend, "extract from detrend database?"}, -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/dvo/photometry.c
r35416 r36680 662 662 break; 663 663 case AVE_dMAG: 664 value = Phot dM(code, average, secfilt);664 value = PhotAveErr (code, average, secfilt); 665 665 break; 666 666 case AVE_Xm: … … 865 865 /* for ErrSelect, check average errors */ 866 866 if (ErrSelect) { 867 dM = Phot dM(code, average, secfilt);867 dM = PhotAveErr (code, average, secfilt); 868 868 if (dM > ErrValue) return (FALSE); 869 869 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/dvo/showtile.c
r34584 r36680 34 34 coords.pc1_2 = coords.pc2_1 = 0.0; 35 35 coords.Npolyterms = 0; 36 strcpy (coords.ctype, " RA---TAN");36 strcpy (coords.ctype, "DEC--TAN"); 37 37 38 38 /* fill in top-left region */ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/dvo/simage.c
r34584 r36680 43 43 /* get astrometry information */ 44 44 strcpy (coords.ctype, "NONE"); 45 gfits_scan (&header, "CTYPE 1", "%s", 1, coords.ctype);46 if (strcmp (coords.ctype, " RA---PLY")) {45 gfits_scan (&header, "CTYPE2", "%s", 1, coords.ctype); 46 if (strcmp (coords.ctype, "DEC--PLY")) { 47 47 gprint (GP_ERR, "ERROR: wrong astrometric info in header\n"); 48 48 return (FALSE); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/include/data.h
r34584 r36680 33 33 char **pageIDs; 34 34 } Book; 35 36 // the interpolating spline has valu 37 typedef struct { 38 int Nknots; 39 opihi_flt *xk; 40 opihi_flt *yk; 41 opihi_flt *y2; 42 char *name; 43 } Spline; 44 45 typedef struct { 46 char *name; 47 int Ninput; 48 int Nx; 49 int Ny; 50 float **buffers; 51 } MedImageType; 35 52 36 53 void InitData (void); … … 144 161 145 162 /* starfuncs.c */ 146 double get_aperture_stats (Matrix *matrix, int X, int Y, int Npix, int Nborder, double max );163 double get_aperture_stats (Matrix *matrix, int X, int Y, int Npix, int Nborder, double max, int VERBOSE); 147 164 int set_rough_radii (double Ra, double Ri, double Ro); 148 165 int get_rough_star (float *data, int Nx, int Ny, int x, int y, opihi_flt *xc, opihi_flt *yc, opihi_flt *sx, opihi_flt *sy, opihi_flt *sxy, opihi_flt *zs, opihi_flt *zp, opihi_flt *sk); … … 170 187 void FreeQueues (void); 171 188 void FreeBooks (void); 172 173 // the interpolating spline has valu174 typedef struct {175 int Nknots;176 opihi_flt *xk;177 opihi_flt *yk;178 opihi_flt *y2;179 char *name;180 } Spline;181 189 182 190 /* in SplineOps.c */ … … 207 215 double hermitian_10(double x); 208 216 217 /* in MedImageOps.c */ 218 void InitMedImages (); 219 void FreeMedImages (); 220 void FreeMedImage (MedImageType *medimage); 221 MedImageType *FindMedImage (char *name); 222 MedImageType *CreateMedImage (char *name, int Nx, int Ny); 223 int DeleteMedImage (MedImageType *medimage); 224 void ListMedImages (); 225 209 226 # endif -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/include/dvomath.h
r33662 r36680 55 55 } Buffer; 56 56 57 typedef enum { 58 ST_NONE, 59 ST_LEFT, 60 ST_RIGHT, 61 ST_COMMA, 62 ST_TRINARY, 63 ST_OR, 64 ST_AND, 65 ST_LOGIC, 66 ST_BITWISE, 67 ST_ADD, 68 ST_TIMES, 69 ST_POWER, 70 ST_UNARY, 71 ST_BINARY, 72 73 ST_VALUE, 74 ST_SCALAR_INT, 75 ST_SCALAR_FLT, 76 ST_VECTOR, 77 ST_VECTOR_TMP, 78 ST_MATRIX, 79 ST_MATRIX_TMP, 80 81 ST_STRING, 82 ST_STRING_TMP, 83 } StackVarType; 84 57 85 typedef struct { /* math stack structure */ 58 86 char *name; 59 chartype;87 StackVarType type; 60 88 Buffer *buffer; 61 89 Vector *vector; … … 77 105 void delete_stack PROTO((StackVar *stack, int Nstack)); 78 106 void clear_stack PROTO((StackVar *stack)); 79 void assign_stack PROTO((StackVar *stack, char *name, int type)); 107 void assign_stack PROTO((StackVar *stack, char *name, StackVarType type)); 108 109 int SSS_trinary PROTO((StackVar *OUT, StackVar *V1, StackVar *V2, StackVar *V3, char *op)); 110 int VVV_trinary PROTO((StackVar *OUT, StackVar *V1, StackVar *V2, StackVar *V3, char *op)); 111 int MMM_trinary PROTO((StackVar *OUT, StackVar *V1, StackVar *V2, StackVar *V3, char *op)); 80 112 81 113 int VV_binary PROTO((StackVar *OUT, StackVar *V1, StackVar *V2, char *op)); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/include/pantasks.h
r32632 r36680 116 116 117 117 int active; 118 int priority;118 int nicelevel; 119 119 120 120 } Task; … … 161 161 162 162 JobMode mode; /* local or controller? */ 163 int priority;163 int nicelevel; 164 164 char *realhost; 165 165 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/include/pcontrol.h
r33662 r36680 8 8 /** job status values **/ 9 9 typedef enum { 10 PCONTROL_JOB_NONE, // XXX OK? 10 11 PCONTROL_JOB_ALLJOBS, 11 12 PCONTROL_JOB_PENDING, … … 119 120 int exit_status; 120 121 int Reset; 121 int priority;122 int nicelevel; 122 123 JobMode mode; 123 124 JobStat state; … … 309 310 char *GetJobStackName (int StackID); 310 311 Stack *GetJobStackByName (char *name); 312 int GetJobStackIDbyName (char *name); 311 313 int PutJob (Job *job, int StackID, int where); 312 314 int PutJobSetState (Job *job, int StackID, int where, int state); 313 315 Job *PullJobByID (IDtype JobID, int *StackID); 314 316 Job *PullJobFromStackByID (int StackID, int ID); 315 IDtype AddJob (char *hostname, JobMode mode, int timeout, int priority, int argc, char **argv, int Nxhosts, char **xhosts);317 IDtype AddJob (char *hostname, JobMode mode, int timeout, int nicelevel, int argc, char **argv, int Nxhosts, char **xhosts); 316 318 void DelJob (Job *job); 317 319 Host *UnlinkJobAndHost (Job *job); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/lib.data/Makefile
r34584 r36680 24 24 $(SDIR)/spline.$(ARCH).o \ 25 25 $(SDIR)/SplineOps.$(ARCH).o \ 26 $(SDIR)/MedImageOps.$(ARCH).o \ 26 27 $(SDIR)/mrqmin.$(ARCH).o \ 27 28 $(SDIR)/mrq2dmin.$(ARCH).o \ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/lib.data/starfuncs.c
r34088 r36680 1 1 # include "data.h" 2 2 3 double get_aperture_stats (Matrix *matrix, int X, int Y, int Npix, int Nborder, double max ) {3 double get_aperture_stats (Matrix *matrix, int X, int Y, int Npix, int Nborder, double max, int VERBOSE) { 4 4 5 5 double *ring; … … 95 95 set_int_variable ("Npts", Npts); 96 96 97 gprint (GP_LOG, "%f %f %f %f %f %f %f %f\n", x, y, FWHMx, FWHMy, sky, I, mag, dmag);97 if (VERBOSE) gprint (GP_LOG, "%f %f %f %f %f %f %f %f\n", x, y, FWHMx, FWHMy, sky, I, mag, dmag); 98 98 99 99 return (mag); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/lib.shell/ListOps.c
r33963 r36680 189 189 int is_list_data (char *line) { 190 190 191 char *comm , *temp;192 193 temp = thisword (nextword (nextword (line)));194 comm = thisword (line); 195 191 char *comm = NULL; 192 char *temp = NULL; 193 char *ptr = NULL; 194 195 comm = thisword (line); 196 196 if (comm == NULL) goto escape; 197 198 197 if (strcmp (comm, "list")) goto escape; 198 199 ptr = nextword (line); 200 if (!strncmp("-excel", ptr, strlen("-excel"))) ptr = nextword (ptr); 201 if (!strncmp("-excel-style", ptr, strlen("-excel-style"))) ptr = nextword (ptr); 202 temp = thisword (ptr); 199 203 200 204 /* if (cond) (command) does not define a complete block */ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/lib.shell/check_stack.c
r34260 r36680 12 12 13 13 for (i = 0; i < Nstack; i++) { 14 if (stack[i].type == 'X') {14 if (stack[i].type == ST_VALUE) { 15 15 16 16 /** if this is a number, put it on the list of scalars and move on. assume value is … … 27 27 stack[i].IntValue = strtol (stack[i].name, &c2, 0); 28 28 if ((fabs(stack[i].FltValue) > MAX_INT) && (c1 == stack[i].name + strlen (stack[i].name))) { 29 stack[i].type = 'S'; // 'S' ==(float)29 stack[i].type = ST_SCALAR_FLT; // (float) 30 30 continue; 31 31 } 32 32 if (c2 == stack[i].name + strlen (stack[i].name)) { 33 stack[i].type = 's'; // 's' ==(int)33 stack[i].type = ST_SCALAR_INT; // (int) 34 34 continue; 35 35 } 36 36 if (c1 == stack[i].name + strlen (stack[i].name)) { 37 stack[i].type = 'S'; // 'S' ==(float)37 stack[i].type = ST_SCALAR_FLT; // (float) 38 38 continue; 39 39 } … … 42 42 if (IsBuffer (stack[i].name)) { 43 43 stack[i].buffer = SelectBuffer (stack[i].name, OLDBUFFER, TRUE); 44 stack[i].type = 'M';44 stack[i].type = ST_MATRIX; 45 45 if (Nx == -1) { 46 46 Nx = stack[i].buffer[0].matrix.Naxis[0]; … … 63 63 if (IsVector (stack[i].name)) { 64 64 stack[i].vector = SelectVector (stack[i].name, OLDVECTOR, FALSE); 65 stack[i].type = 'V';65 stack[i].type = ST_VECTOR; 66 66 67 67 if (Nv == -1) Nv = stack[i].vector[0].Nelements; … … 80 80 81 81 /* this is not a scalar, vector, or matrix. must be string */ 82 stack[i].type = 'W';82 stack[i].type = ST_STRING; 83 83 } 84 84 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/lib.shell/convert_to_RPN.c
r34088 r36680 4 4 StackVar *convert_to_RPN (int argc, char **argv, int *nstack) { 5 5 6 inttype;6 StackVarType type; 7 7 int i, j, Nstack, Nop_stack, NSTACK; 8 8 StackVar *stack, *op_stack; … … 21 21 22 22 /* decide on priority of object */ 23 type = 0; 23 type = ST_NONE; 24 25 /* trinary operations */ 26 if (!strcmp (argv[i], "?")) { type = ST_TRINARY; goto gotit; } 27 if (!strcmp (argv[i], ":")) { type = ST_COMMA; goto gotit; } 28 24 29 /* unary operations */ 25 if (!strcmp (argv[i], "abs")) { type = 9; goto gotit; }26 if (!strcmp (argv[i], "int")) { type = 9; goto gotit; }27 if (!strcmp (argv[i], " exp")) { type = 9; goto gotit; }28 if (!strcmp (argv[i], " ten")) { type = 9; goto gotit; }29 if (!strcmp (argv[i], " log")) { type = 9; goto gotit; }30 if (!strcmp (argv[i], " ln")) { type = 9; goto gotit; }31 if (!strcmp (argv[i], " sqrt")) { type = 9; goto gotit; }32 if (!strcmp (argv[i], " erf")) { type = 9; goto gotit; }33 34 if (!strcmp (argv[i], " sinh")) { type = 9; goto gotit; }35 if (!strcmp (argv[i], " cosh")) { type = 9; goto gotit; }36 if (!strcmp (argv[i], " asinh")) { type = 9; goto gotit; }37 if (!strcmp (argv[i], " acosh")) { type = 9; goto gotit; }38 39 if (!strcmp (argv[i], " sin")) { type = 9; goto gotit; }40 if (!strcmp (argv[i], " cos")) { type = 9; goto gotit; }41 if (!strcmp (argv[i], " tan")) { type = 9; goto gotit; }42 if (!strcmp (argv[i], " dsin")) { type = 9; goto gotit; }43 if (!strcmp (argv[i], " dcos")) { type = 9; goto gotit; }44 if (!strcmp (argv[i], "d tan")) { type = 9; goto gotit; }45 if (!strcmp (argv[i], " asin")) { type = 9; goto gotit; }46 if (!strcmp (argv[i], " acos")) { type = 9; goto gotit; }47 if (!strcmp (argv[i], "a tan")) { type = 9; goto gotit; }48 if (!strcmp (argv[i], " dasin")) { type = 9; goto gotit; }49 if (!strcmp (argv[i], " dacos")) { type = 9; goto gotit; }50 if (!strcmp (argv[i], "da tan")) { type = 9; goto gotit; }51 52 if (!strcmp (argv[i], " lgamma")) { type = 9; goto gotit; }53 54 if (!strcmp (argv[i], "rnd")) { type = 9; goto gotit; }55 if (!strcmp (argv[i], "xramp")) { type = 9; goto gotit; }56 if (!strcmp (argv[i], "yramp")) { type = 9; goto gotit; }57 if (!strcmp (argv[i], "ramp")) { type = 9; goto gotit; }58 if (!strcmp (argv[i], "zero")) { type = 9; goto gotit; }59 if (!strcmp (argv[i], "--")) { type = 9; goto gotit; }60 if (!strcmp (argv[i], "not")) { type = 9; goto gotit; }61 if (!strcmp (argv[i], "isinf")) { type = 9; goto gotit; }62 if (!strcmp (argv[i], "isnan")) { type = 9; goto gotit; }30 if (!strcmp (argv[i], "abs")) { type = ST_UNARY; goto gotit; } 31 if (!strcmp (argv[i], "int")) { type = ST_UNARY; goto gotit; } 32 if (!strcmp (argv[i], "floor")) { type = ST_UNARY; goto gotit; } 33 if (!strcmp (argv[i], "round")) { type = ST_UNARY; goto gotit; } 34 if (!strcmp (argv[i], "ceil")) { type = ST_UNARY; goto gotit; } 35 if (!strcmp (argv[i], "rint")) { type = ST_UNARY; goto gotit; } 36 if (!strcmp (argv[i], "exp")) { type = ST_UNARY; goto gotit; } 37 if (!strcmp (argv[i], "ten")) { type = ST_UNARY; goto gotit; } 38 if (!strcmp (argv[i], "log")) { type = ST_UNARY; goto gotit; } 39 if (!strcmp (argv[i], "ln")) { type = ST_UNARY; goto gotit; } 40 if (!strcmp (argv[i], "sqrt")) { type = ST_UNARY; goto gotit; } 41 if (!strcmp (argv[i], "erf")) { type = ST_UNARY; goto gotit; } 42 if (!strcmp (argv[i], "sinh")) { type = ST_UNARY; goto gotit; } 43 if (!strcmp (argv[i], "cosh")) { type = ST_UNARY; goto gotit; } 44 if (!strcmp (argv[i], "asinh")) { type = ST_UNARY; goto gotit; } 45 if (!strcmp (argv[i], "acosh")) { type = ST_UNARY; goto gotit; } 46 if (!strcmp (argv[i], "sin")) { type = ST_UNARY; goto gotit; } 47 if (!strcmp (argv[i], "cos")) { type = ST_UNARY; goto gotit; } 48 if (!strcmp (argv[i], "tan")) { type = ST_UNARY; goto gotit; } 49 if (!strcmp (argv[i], "dsin")) { type = ST_UNARY; goto gotit; } 50 if (!strcmp (argv[i], "dcos")) { type = ST_UNARY; goto gotit; } 51 if (!strcmp (argv[i], "dtan")) { type = ST_UNARY; goto gotit; } 52 if (!strcmp (argv[i], "asin")) { type = ST_UNARY; goto gotit; } 53 if (!strcmp (argv[i], "acos")) { type = ST_UNARY; goto gotit; } 54 if (!strcmp (argv[i], "atan")) { type = ST_UNARY; goto gotit; } 55 if (!strcmp (argv[i], "dasin")) { type = ST_UNARY; goto gotit; } 56 if (!strcmp (argv[i], "dacos")) { type = ST_UNARY; goto gotit; } 57 if (!strcmp (argv[i], "datan")) { type = ST_UNARY; goto gotit; } 58 if (!strcmp (argv[i], "lgamma")) { type = ST_UNARY; goto gotit; } 59 if (!strcmp (argv[i], "rnd")) { type = ST_UNARY; goto gotit; } 60 if (!strcmp (argv[i], "xramp")) { type = ST_UNARY; goto gotit; } 61 if (!strcmp (argv[i], "yramp")) { type = ST_UNARY; goto gotit; } 62 if (!strcmp (argv[i], "ramp")) { type = ST_UNARY; goto gotit; } 63 if (!strcmp (argv[i], "zero")) { type = ST_UNARY; goto gotit; } 64 if (!strcmp (argv[i], "--")) { type = ST_UNARY; goto gotit; } 65 if (!strcmp (argv[i], "not")) { type = ST_UNARY; goto gotit; } 66 if (!strcmp (argv[i], "isinf")) { type = ST_UNARY; goto gotit; } 67 if (!strcmp (argv[i], "isnan")) { type = ST_UNARY; goto gotit; } 63 68 64 69 /* binary operations */ 65 if (!strcmp (argv[i], "^")) { type = 8; goto gotit; } 66 67 if (!strcmp (argv[i], "@")) { type = 7; goto gotit; } 68 if (!strcmp (argv[i], "/")) { type = 7; goto gotit; } 69 if (!strcmp (argv[i], "*")) { type = 7; goto gotit; } 70 if (!strcmp (argv[i], "%")) { type = 7; goto gotit; } 71 72 if (!strcmp (argv[i], "+")) { type = 6; goto gotit; } 73 if (!strcmp (argv[i], "-")) { type = 6; goto gotit; } 70 if (!strcmp (argv[i], "^")) { type = ST_POWER; goto gotit; } 71 72 if (!strcmp (argv[i], "max")) { type = ST_BINARY; strcpy (argv[i], "U"); goto gotit; } 73 if (!strcmp (argv[i], "min")) { type = ST_BINARY; strcpy (argv[i], "D"); goto gotit; } 74 if (!strcmp (argv[i], "atan2")) { type = ST_BINARY; goto gotit; } 75 if (!strcmp (argv[i], ",")) { type = ST_COMMA; goto gotit; } 76 77 if (!strcmp (argv[i], "@")) { type = ST_TIMES; goto gotit; } 78 if (!strcmp (argv[i], "/")) { type = ST_TIMES; goto gotit; } 79 if (!strcmp (argv[i], "*")) { type = ST_TIMES; goto gotit; } 80 if (!strcmp (argv[i], "%")) { type = ST_TIMES; goto gotit; } 81 82 if (!strcmp (argv[i], "+")) { type = ST_ADD; goto gotit; } 83 if (!strcmp (argv[i], "-")) { type = ST_ADD; goto gotit; } 74 84 75 if (!strcmp (argv[i], "&")) { type = 5; goto gotit; }76 if (!strcmp (argv[i], "|")) { type = 5; goto gotit; }77 78 if (!strcmp (argv[i], "<")) { type = 4; goto gotit; }79 if (!strcmp (argv[i], ">")) { type = 4; goto gotit; }80 if (!strcmp (argv[i], "==")) { type = 4; strcpy (argv[i], "E"); goto gotit; }81 if (!strcmp (argv[i], "!=")) { type = 4; strcpy (argv[i], "N"); goto gotit; }82 if (!strcmp (argv[i], "<=")) { type = 4; strcpy (argv[i], "L"); goto gotit; }83 if (!strcmp (argv[i], ">=")) { type = 4; strcpy (argv[i], "G"); goto gotit; }84 if (!strcmp (argv[i], ">>")) { type = 4; strcpy (argv[i], "U"); goto gotit; }85 if (!strcmp (argv[i], "<<")) { type = 4; strcpy (argv[i], "D"); goto gotit; }86 87 if (!strcmp (argv[i], "&&")) { type = 3; strcpy (argv[i], "A"); goto gotit; }88 if (!strcmp (argv[i], "||")) { type = 3; strcpy (argv[i], "O"); goto gotit; }89 90 if (!strcmp (argv[i], "(")) { type = 2;goto gotit; }91 if (!strcmp (argv[i], ")")) { type = 1; goto gotit; }85 if (!strcmp (argv[i], "&")) { type = ST_BITWISE; goto gotit; } 86 if (!strcmp (argv[i], "|")) { type = ST_BITWISE; goto gotit; } 87 88 if (!strcmp (argv[i], "<")) { type = ST_LOGIC; goto gotit; } 89 if (!strcmp (argv[i], ">")) { type = ST_LOGIC; goto gotit; } 90 if (!strcmp (argv[i], "==")) { type = ST_LOGIC; strcpy (argv[i], "E"); goto gotit; } 91 if (!strcmp (argv[i], "!=")) { type = ST_LOGIC; strcpy (argv[i], "N"); goto gotit; } 92 if (!strcmp (argv[i], "<=")) { type = ST_LOGIC; strcpy (argv[i], "L"); goto gotit; } 93 if (!strcmp (argv[i], ">=")) { type = ST_LOGIC; strcpy (argv[i], "G"); goto gotit; } 94 if (!strcmp (argv[i], ">>")) { type = ST_LOGIC; strcpy (argv[i], "U"); goto gotit; } 95 if (!strcmp (argv[i], "<<")) { type = ST_LOGIC; strcpy (argv[i], "D"); goto gotit; } 96 97 if (!strcmp (argv[i], "&&")) { type = ST_AND; strcpy (argv[i], "A"); goto gotit; } 98 if (!strcmp (argv[i], "||")) { type = ST_OR ; strcpy (argv[i], "O"); goto gotit; } 99 100 if (!strcmp (argv[i], "(")) { type = ST_LEFT; goto gotit; } 101 if (!strcmp (argv[i], ")")) { type = ST_RIGHT; goto gotit; } 92 102 93 103 gotit: 94 104 /* choose how to deal with object */ 95 105 switch (type) { 96 case 8: /* exponentiation: 2^2^3 = 64 != 256 (precedence is right-to-left, not left-to-right!) */106 case ST_POWER: /* exponentiation: 2^2^3 = 64 != 256 (precedence is right-to-left, not left-to-right!) */ 97 107 /* pop previous, higher operators from OP stack to stack */ 98 108 for (j = Nop_stack - 1; (j >= 0) && (op_stack[j].type > type); j--) { … … 105 115 Nop_stack ++; 106 116 break; 107 case 9: /* unary OPs */ 108 case 7: /* binary OPs */ 109 case 6: 110 case 5: 111 case 4: 112 case 3: 117 case ST_UNARY: 118 case ST_BINARY: 119 case ST_TRINARY: 120 case ST_TIMES: 121 case ST_ADD: 122 case ST_BITWISE: 123 case ST_LOGIC: 124 case ST_AND: 125 case ST_OR: 113 126 /* pop previous, higher or equal operators from OP stack to stack */ 114 127 for (j = Nop_stack - 1; (j >= 0) && (op_stack[j].type >= type); j--) { … … 121 134 Nop_stack ++; 122 135 break; 123 case 2:136 case ST_LEFT: 124 137 /* push operator on OP stack */ 125 138 assign_stack (&op_stack[Nop_stack], argv[i], type); … … 127 140 Nop_stack ++; 128 141 break; 129 case 1:142 case ST_RIGHT: 130 143 /* pop rest of operators from OP stack to stack, looking for '(' */ 131 for (j = Nop_stack - 1; (j >= 0) && (op_stack[j].type != 2); j--) {132 move_stack (&stack[Nstack], &op_stack[j]); 133 Nstack ++; 134 Nop_stack --; 135 } 136 if ((j == -1) || (op_stack[j].type != 2)) {144 for (j = Nop_stack - 1; (j >= 0) && (op_stack[j].type != ST_LEFT); j--) { 145 move_stack (&stack[Nstack], &op_stack[j]); 146 Nstack ++; 147 Nop_stack --; 148 } 149 if ((j == -1) || (op_stack[j].type != ST_LEFT)) { 137 150 push_error ("syntax error: mismatched parenthesis"); 138 151 Nstack = 0; … … 144 157 Nop_stack --; 145 158 break; 146 case 0: 159 case ST_COMMA: 160 /* pop rest of operators from OP stack to stack, looking for '(' (but do not pop the '(')*/ 161 for (j = Nop_stack - 1; (j >= 0) && (op_stack[j].type != ST_LEFT) && (op_stack[j].type != ST_TRINARY); j--) { 162 move_stack (&stack[Nstack], &op_stack[j]); 163 Nstack ++; 164 Nop_stack --; 165 } 166 break; 167 case ST_NONE: 147 168 /* place the value (number or vector/matrix name) on stack */ 148 169 /* value of 'X' is used as sentinel until we sort out values */ 149 assign_stack (&stack[Nstack], argv[i], 'X');170 assign_stack (&stack[Nstack], argv[i], ST_VALUE); 150 171 Nstack ++; 151 172 break; 173 174 default: 175 push_error ("invalid stack typ"); 176 Nstack = 0; 177 goto cleanup; 152 178 } 153 179 } 154 180 155 /* dump remaining operators on stack, checking for ' )' */181 /* dump remaining operators on stack, checking for '(' */ 156 182 for (j = Nop_stack - 1; j >= 0; j--) { 157 if (op_stack[j].type == 2) {183 if (op_stack[j].type == ST_LEFT) { 158 184 push_error ("syntax error: mismatched parenthesis"); 159 185 Nstack = 0; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/lib.shell/dvomath.c
r31635 r36680 80 80 sprintf (outname, "%s", stack[0].name); 81 81 } else { 82 if (stack[0].type == 's') {82 if (stack[0].type == ST_SCALAR_INT) { 83 83 sprintf (outname, "%d", stack[0].IntValue); 84 84 } else { -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/lib.shell/evaluate_stack.c
r34088 r36680 2 2 # define VERBOSE 0 3 3 4 # define TWO_OP(A,B,FUNC) \ 5 if (!strncasecmp (&stack[i - 2].type, A, 1) && !strncasecmp (&stack[i - 1].type, B, 1)) \ 6 status = FUNC (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name); 7 8 # define ONE_OP(A,FUNC) \ 9 if (!strncasecmp (&stack[i - 1].type, A, 1)) \ 10 status = FUNC (&tmp_stack, &stack[i - 1], stack[i].name); 4 // all three operands must have the same type 5 # define THREE_OP(A,FUNC) \ 6 if ((stack[i - 3].type == A) && (stack[i - 2].type == A) && (stack[i - 1].type == A)) { \ 7 status = FUNC (&tmp_stack, &stack[i - 3], &stack[i - 2], &stack[i - 1], stack[i].name); \ 8 goto got_three_op; } \ 9 if ((stack[i - 3].type == A+1) && (stack[i - 2].type == A) && (stack[i - 1].type == A)) { \ 10 status = FUNC (&tmp_stack, &stack[i - 3], &stack[i - 2], &stack[i - 1], stack[i].name); \ 11 goto got_three_op; } \ 12 if ((stack[i - 3].type == A) && (stack[i - 2].type == A+1) && (stack[i - 1].type == A)) { \ 13 status = FUNC (&tmp_stack, &stack[i - 3], &stack[i - 2], &stack[i - 1], stack[i].name); \ 14 goto got_three_op; } \ 15 if ((stack[i - 3].type == A+1) && (stack[i - 2].type == A+1) && (stack[i - 1].type == A)) { \ 16 status = FUNC (&tmp_stack, &stack[i - 3], &stack[i - 2], &stack[i - 1], stack[i].name); \ 17 goto got_three_op; } \ 18 if ((stack[i - 3].type == A) && (stack[i - 2].type == A) && (stack[i - 1].type == A+1)) { \ 19 status = FUNC (&tmp_stack, &stack[i - 3], &stack[i - 2], &stack[i - 1], stack[i].name); \ 20 goto got_three_op; } \ 21 if ((stack[i - 3].type == A+1) && (stack[i - 2].type == A) && (stack[i - 1].type == A+1)) { \ 22 status = FUNC (&tmp_stack, &stack[i - 3], &stack[i - 2], &stack[i - 1], stack[i].name); \ 23 goto got_three_op; } \ 24 if ((stack[i - 3].type == A) && (stack[i - 2].type == A+1) && (stack[i - 1].type == A+1)) { \ 25 status = FUNC (&tmp_stack, &stack[i - 3], &stack[i - 2], &stack[i - 1], stack[i].name); \ 26 goto got_three_op; } \ 27 if ((stack[i - 3].type == A+1) && (stack[i - 2].type == A+1) && (stack[i - 1].type == A+1)) { \ 28 status = FUNC (&tmp_stack, &stack[i - 3], &stack[i - 2], &stack[i - 1], stack[i].name); \ 29 goto got_three_op; } \ 30 31 // A & B value types all have 2 possible values 32 # define TWO_OP(A,B,FUNC) { \ 33 if ((stack[i - 2].type == A) && (stack[i - 1].type == B)) { \ 34 status = FUNC (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name); \ 35 goto got_two_op; } \ 36 if ((stack[i - 2].type == A+1) && (stack[i - 1].type == B)) { \ 37 status = FUNC (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name); \ 38 goto got_two_op; } \ 39 if ((stack[i - 2].type == A) && (stack[i - 1].type == B+1)) { \ 40 status = FUNC (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name); \ 41 goto got_two_op; } \ 42 if ((stack[i - 2].type == A+1) && (stack[i - 1].type == B+1)) { \ 43 status = FUNC (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name); \ 44 goto got_two_op; } \ 45 } 46 47 # define ONE_OP(A,FUNC) \ 48 if (stack[i - 1].type == A) { \ 49 status = FUNC (&tmp_stack, &stack[i - 1], stack[i].name); \ 50 goto got_one_op; } 11 51 12 52 int evaluate_stack (StackVar *stack, int *Nstack) { … … 20 60 21 61 if (*Nstack == 1) { 22 if ((stack[0].type == 'S') || (stack[0].type == 's')) {62 if ((stack[0].type == ST_SCALAR_INT) || (stack[0].type == ST_SCALAR_FLT)) { 23 63 clear_stack (&tmp_stack); 24 64 return (TRUE); 25 65 } 26 if (stack[0].type == 'V') {66 if (stack[0].type == ST_VECTOR) { 27 67 /* need to make a copy so we set output value? */ 28 68 V_unary (&tmp_stack, &stack[0], "="); … … 30 70 return (TRUE); 31 71 } 32 if (stack[0].type == 'M') {72 if (stack[0].type == ST_MATRIX) { 33 73 /* need to make a copy so we set output value? */ 34 74 M_unary (&tmp_stack, &stack[0], "="); … … 56 96 } 57 97 58 /***** binary operators *****/ 59 if ((stack[i].type >= 3) && (stack[i].type <= 8)) { 60 61 if (i < 2) { /* need two variables to operate on */ 62 sprintf (line, "syntax error: binary operator with one operand: %s\n", stack[i].name); 98 /***** trinary operators *****/ 99 switch (stack[i].type) { 100 case ST_TRINARY: 101 102 if (i < 3) { /* need two variables to operate on */ 103 snprintf (line, 512, "syntax error: trinary operator without three operands: %s\n", stack[i].name); 104 push_error (line); 105 clear_stack (&tmp_stack); 106 return (FALSE); 107 } 108 109 status = FALSE; 110 THREE_OP (ST_MATRIX,MMM_trinary); 111 THREE_OP (ST_VECTOR,VVV_trinary); 112 113 THREE_OP (ST_SCALAR_FLT,SSS_trinary); 114 THREE_OP (ST_SCALAR_INT,SSS_trinary); 115 116 /* there are no valid unary string operators */ 117 push_error ("invalid operands for trinary operator (mismatch types?)"); 118 clear_stack (&tmp_stack); 119 return (FALSE); 120 121 got_three_op: 122 if (!status) { 123 snprintf (line, 512, "syntax error: invalid operand for binary operation: %s or %s or %s\n", stack[i-1].name, stack[i-2].name, stack[i-3].name); 124 push_error (line); 125 clear_stack (&tmp_stack); 126 return (FALSE); 127 } 128 move_stack (&stack[i-3], &tmp_stack); 129 delete_stack (&stack[i-2], 3); 130 for (j = i + 1; j < *Nstack; j++) { 131 move_stack (&stack[j-3], &stack[j]); 132 } 133 *Nstack -= 3; 134 i -= 3; 135 init_stack (&tmp_stack); 136 continue; 137 138 /***** binary operators *****/ 139 case ST_OR: 140 case ST_AND: 141 case ST_LOGIC: 142 case ST_BITWISE: 143 case ST_ADD: 144 case ST_TIMES: 145 case ST_POWER: 146 case ST_BINARY: 147 148 if (i < 2) { /* need two variables to operate on */ 149 snprintf (line, 512, "syntax error: binary operator with one operand: %s\n", stack[i].name); 150 push_error (line); 151 clear_stack (&tmp_stack); 152 return (FALSE); 153 } 154 155 status = FALSE; 156 TWO_OP (ST_MATRIX,ST_MATRIX,MM_binary); 157 TWO_OP (ST_MATRIX,ST_VECTOR,MV_binary); 158 TWO_OP (ST_MATRIX,ST_SCALAR_INT,MS_binary); 159 160 TWO_OP (ST_VECTOR,ST_MATRIX,VM_binary); 161 TWO_OP (ST_VECTOR,ST_VECTOR,VV_binary); 162 TWO_OP (ST_VECTOR,ST_SCALAR_INT,VS_binary); 163 164 TWO_OP (ST_SCALAR_INT,ST_MATRIX,SM_binary); 165 TWO_OP (ST_SCALAR_INT,ST_VECTOR,SV_binary); 166 TWO_OP (ST_SCALAR_INT,ST_SCALAR_INT,SS_binary); 167 168 TWO_OP (ST_SCALAR_FLT,ST_MATRIX,SM_binary); 169 TWO_OP (ST_SCALAR_FLT,ST_VECTOR,SV_binary); 170 TWO_OP (ST_SCALAR_FLT,ST_SCALAR_INT,SS_binary); 171 172 TWO_OP (ST_STRING,ST_STRING,WW_binary); 173 TWO_OP (ST_STRING,ST_SCALAR_INT,WW_binary); 174 TWO_OP (ST_SCALAR_INT,ST_STRING,WW_binary); 175 176 got_two_op: 177 if (!status) { 178 snprintf (line, 512, "syntax error: invalid operand for binary operation: %s or %s\n", stack[i-1].name, stack[i-2].name); 179 push_error (line); 180 clear_stack (&tmp_stack); 181 return (FALSE); 182 } 183 move_stack (&stack[i-2], &tmp_stack); 184 delete_stack (&stack[i-1], 2); 185 for (j = i + 1; j < *Nstack; j++) { 186 move_stack (&stack[j - 2], &stack[j]); 187 } 188 *Nstack -= 2; 189 i -= 2; 190 init_stack (&tmp_stack); 191 continue; 192 193 /***** unary operators **/ 194 case ST_UNARY: 195 196 if (i < 1) { /* need one variable to operate on */ 197 push_error ("syntax error: unary operator with no operand"); 198 clear_stack (&tmp_stack); 199 return (FALSE); 200 } 201 202 ONE_OP (ST_MATRIX, M_unary); 203 ONE_OP (ST_MATRIX_TMP, M_unary); 204 205 ONE_OP (ST_VECTOR, V_unary); 206 ONE_OP (ST_VECTOR_TMP, V_unary); 207 208 ONE_OP (ST_SCALAR_INT, S_unary); 209 ONE_OP (ST_SCALAR_FLT, S_unary); 210 211 /* there are no valid unary string operators */ 212 push_error ("syntax error: no valid string unary ops"); 213 clear_stack (&tmp_stack); 214 return (FALSE); 215 216 got_one_op: 217 move_stack (&stack[i-1], &tmp_stack); 218 delete_stack (&stack[i], 1); 219 for (j = i + 1; j < *Nstack; j++) { 220 move_stack (&stack[j - 1], &stack[j]); 221 } 222 init_stack (&tmp_stack); 223 *Nstack -= 1; 224 i -= 1; 225 continue; 226 227 case ST_SCALAR_INT: 228 case ST_SCALAR_FLT: 229 case ST_VECTOR: 230 case ST_VECTOR_TMP: 231 case ST_MATRIX: 232 case ST_MATRIX_TMP: 233 case ST_STRING: 234 continue; 235 236 default: 237 snprintf (line, 512, "syntax error: unexpected operator type %s", stack[i].name); 63 238 push_error (line); 64 239 clear_stack (&tmp_stack); 65 240 return (FALSE); 66 } 67 68 status = FALSE; 69 TWO_OP ("M","M",MM_binary); 70 TWO_OP ("M","V",MV_binary); 71 TWO_OP ("M","S",MS_binary); 72 TWO_OP ("V","M",VM_binary); 73 TWO_OP ("V","V",VV_binary); 74 TWO_OP ("V","S",VS_binary); 75 TWO_OP ("S","M",SM_binary); 76 TWO_OP ("S","V",SV_binary); 77 TWO_OP ("S","S",SS_binary); 78 TWO_OP ("W","W",WW_binary); 79 TWO_OP ("W","S",WW_binary); 80 TWO_OP ("S","W",WW_binary); 81 82 if (!status) { 83 sprintf (line, "syntax error: invalid operand for binary operation: %s or %s\n", stack[i-1].name, stack[i-2].name); 84 push_error (line); 85 clear_stack (&tmp_stack); 86 return (FALSE); 87 } 88 move_stack (&stack[i-2], &tmp_stack); 89 delete_stack (&stack[i-1], 2); 90 for (j = i + 1; j < *Nstack; j++) { 91 move_stack (&stack[j - 2], &stack[j]); 92 } 93 *Nstack -= 2; 94 i -= 2; 95 init_stack (&tmp_stack); 96 continue; 97 } 98 99 /***** unary operators **/ 100 if (stack[i].type == 9) { 101 102 if (i < 1) { /* need one variable to operate on */ 103 push_error ("syntax error: unary operator with no operand"); 104 clear_stack (&tmp_stack); 105 return (FALSE); 106 } 107 108 ONE_OP ("M", M_unary); 109 ONE_OP ("V", V_unary); 110 ONE_OP ("S", S_unary); 111 112 /* there are no valid unary string operators */ 113 if (!strncasecmp (&stack[i - 1].type, "W", 1)) { 114 push_error ("syntax error: no valid string unary ops"); 115 clear_stack (&tmp_stack); 116 return (FALSE); 117 } 118 119 move_stack (&stack[i-1], &tmp_stack); 120 delete_stack (&stack[i], 1); 121 for (j = i + 1; j < *Nstack; j++) { 122 move_stack (&stack[j - 1], &stack[j]); 123 } 124 init_stack (&tmp_stack); 125 *Nstack -= 1; 126 i -= 1; 127 continue; 128 } 241 } 129 242 } 130 243 clear_stack (&tmp_stack); … … 160 273 161 274 for (i = 0; i < Nstack; i++) { 162 if (IsBufferPtr (stack[i].buffer) && (stack[i].type == 'm')) {275 if (IsBufferPtr (stack[i].buffer) && (stack[i].type == ST_MATRIX_TMP)) { 163 276 if (VERBOSE) gprint (GP_ERR, "free %s (buff) (%lx)\n", stack[i].name, (long) stack[i].buffer); 164 277 free (stack[i].buffer[0].header.buffer); … … 167 280 stack[i].buffer = NULL; 168 281 } 169 if (IsVectorPtr (stack[i].vector) && (stack[i].type == 'v')) {282 if (IsVectorPtr (stack[i].vector) && (stack[i].type == ST_VECTOR_TMP)) { 170 283 if (VERBOSE) gprint (GP_ERR, "free %s (vect) (%lx)\n", stack[i].name, (long) stack[i].vector); 171 284 free (stack[i].vector[0].elements.Ptr); … … 193 306 } 194 307 195 void assign_stack (StackVar *stack, char *name, inttype) {308 void assign_stack (StackVar *stack, char *name, StackVarType type) { 196 309 stack->name = strcreate (name); 197 310 stack->type = type; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/lib.shell/stack_math.c
r34342 r36680 6 6 */ 7 7 8 // XXX we temporarily drop the concept of using one of the temporary input vectors for 9 // the output vector (thus saving an ALLOC): we have to juggle the size of the input vectors 10 // as well as their temporary state 11 12 int VV_binary (StackVar *OUT, StackVar *V1, StackVar *V2, char *op) { 8 int SSS_trinary (StackVar *OUT, StackVar *V1, StackVar *V2, StackVar *V3, char *op) { 9 10 char line[512]; // this is only used to report an error 11 12 // set up the possible operations : int OP int -> int, all else yield float 13 // OP is the operation performed on *M1 and *M2 14 # define SSS_FUNC(OP) { \ 15 if ((V1->type == ST_SCALAR_FLT) && (V2->type == ST_SCALAR_FLT) && (V3->type == ST_SCALAR_FLT)) { \ 16 opihi_flt M1 = V1[0].FltValue; \ 17 opihi_flt M2 = V2[0].FltValue; \ 18 opihi_flt M3 = V3[0].FltValue; \ 19 OUT[0].type = ST_SCALAR_FLT; \ 20 OUT[0].FltValue = OP; \ 21 break; \ 22 } \ 23 if ((V1->type == ST_SCALAR_INT) && (V2->type == ST_SCALAR_INT) && (V3->type == ST_SCALAR_INT)) { \ 24 opihi_int M1 = V1[0].IntValue; \ 25 opihi_int M2 = V2[0].IntValue; \ 26 opihi_int M3 = V3[0].IntValue; \ 27 OUT[0].type = ST_SCALAR_INT; \ 28 OUT[0].IntValue = OP; \ 29 break; \ 30 } \ 31 } 32 33 switch (op[0]) { 34 case '?': SSS_FUNC(M1 ? M2: M3); 35 default: 36 snprintf (line, 512, "error: op %c not defined!", op[0]); 37 push_error (line); 38 return (FALSE); 39 } 40 # undef SSS_FUNC 41 42 clear_stack (V1); 43 clear_stack (V2); 44 clear_stack (V3); 45 return (TRUE); 46 47 } 48 49 int VVV_trinary (StackVar *OUT, StackVar *V1, StackVar *V2, StackVar *V3, char *op) { 13 50 14 51 int i, Nx; … … 19 56 return (FALSE); 20 57 } 58 if (V1[0].vector[0].Nelements != V3[0].vector[0].Nelements) { 59 return (FALSE); 60 } 21 61 22 62 Nx = V1[0].vector[0].Nelements; … … 24 64 // create the output vector guaranteed to be temporary until the very end 25 65 OUT[0].vector = InitVector (); 26 OUT[0].type = 'v'; 66 OUT[0].type = ST_VECTOR_TMP; 67 68 // set up the possible operations : int OP int -> int, all else yield float 69 // OP is the operation performed on *M1 and *M2 70 # define VVV_FUNC(OP) { \ 71 if ((V1->vector->type == OPIHI_FLT) && (V2->vector->type == OPIHI_FLT) && (V3->vector->type == OPIHI_FLT)) { \ 72 CopyVector (OUT[0].vector, V1[0].vector); \ 73 opihi_flt *M1 = V1[0].vector[0].elements.Flt; \ 74 opihi_flt *M2 = V2[0].vector[0].elements.Flt; \ 75 opihi_flt *M3 = V3[0].vector[0].elements.Flt; \ 76 opihi_flt *out = OUT[0].vector[0].elements.Flt; \ 77 for (i = 0; i < Nx; i++, out++, M1++, M2++, M3++) { \ 78 *out = OP; \ 79 } \ 80 break; \ 81 } \ 82 if ((V1->vector->type == OPIHI_INT) && (V2->vector->type == OPIHI_INT) && (V3->vector->type == OPIHI_INT)) { \ 83 CopyVector (OUT[0].vector, V1[0].vector); \ 84 opihi_int *M1 = V1[0].vector[0].elements.Int; \ 85 opihi_int *M2 = V2[0].vector[0].elements.Int; \ 86 opihi_int *M3 = V3[0].vector[0].elements.Int; \ 87 opihi_int *out = OUT[0].vector[0].elements.Int; \ 88 for (i = 0; i < Nx; i++, out++, M1++, M2++, M3++) { \ 89 *out = OP; \ 90 } \ 91 break; \ 92 } \ 93 } 94 95 switch (op[0]) { 96 case '?': VVV_FUNC(*M1 ? *M2: *M3); 97 default: 98 snprintf (line, 512, "error: op %c not defined!", op[0]); 99 push_error (line); 100 return (FALSE); 101 } 102 # undef VVV_FUNC 103 104 /** free up any temporary buffers: **/ 105 106 if (V1[0].type == ST_VECTOR_TMP) { 107 free (V1[0].vector[0].elements.Ptr); 108 free (V1[0].vector); 109 } 110 if (V2[0].type == ST_VECTOR_TMP) { 111 free (V2[0].vector[0].elements.Ptr); 112 free (V2[0].vector); 113 } 114 if (V3[0].type == ST_VECTOR_TMP) { 115 free (V3[0].vector[0].elements.Ptr); 116 free (V3[0].vector); 117 } 118 /* at the end, V1 and V2 are deleted only if they were temporary */ 119 120 clear_stack (V1); 121 clear_stack (V2); 122 clear_stack (V3); 123 return (TRUE); 124 125 } 126 127 int MMM_trinary (StackVar *OUT, StackVar *V1, StackVar *V2, StackVar *V3, char *op) { 128 129 int i, Nx, Ny; 130 float *out, *M1, *M2, *M3; 131 char line[512]; // this is only used to report an error 132 133 Nx = V1[0].buffer[0].matrix.Naxis[0]; 134 Ny = V1[0].buffer[0].matrix.Naxis[1]; 135 136 if (V1[0].type == ST_MATRIX_TMP) { /** use V1 as temp buffer **/ 137 OUT[0].buffer = V1[0].buffer; 138 V1[0].type = ST_MATRIX; /* prevent it from being freed below */ 139 } else { 140 if (V2[0].type == ST_MATRIX_TMP) { /** use V2 as temp buffer, but header of V1 **/ 141 OUT[0].buffer = V2[0].buffer; 142 V2[0].type = ST_MATRIX; /* prevent it from being freed below */ 143 } else { /* no spare temp buffer */ 144 OUT[0].buffer = InitBuffer (); 145 CopyBuffer (OUT[0].buffer, V1[0].buffer); 146 } 147 } 148 OUT[0].type = ST_MATRIX_TMP; /*** <<--- says this is a temporary matrix ***/ 149 150 M1 = (float *)V1[0].buffer[0].matrix.buffer; 151 M2 = (float *)V2[0].buffer[0].matrix.buffer; 152 M3 = (float *)V3[0].buffer[0].matrix.buffer; 153 out = (float *)OUT[0].buffer[0].matrix.buffer; 154 155 # define MMM_FUNC(OP) \ 156 for (i = 0; i < Nx*Ny; i++, out++, M1++, M2++, M3++) { \ 157 *out = OP; \ 158 } \ 159 break; 160 161 switch (op[0]) { 162 case '?': MMM_FUNC(*M1 ? *M2: *M3); 163 default: 164 snprintf (line, 512, "error: op %c not defined!", op[0]); 165 push_error (line); 166 return (FALSE); 167 } 168 # undef MMM_FUNC 169 170 /** free up any temporary buffers: **/ 171 172 if (V1[0].type == ST_MATRIX_TMP) { 173 free (V1[0].buffer[0].header.buffer); 174 free (V1[0].buffer[0].matrix.buffer); 175 free (V1[0].buffer); 176 } 177 if (V2[0].type == ST_MATRIX_TMP) { 178 free (V2[0].buffer[0].header.buffer); 179 free (V2[0].buffer[0].matrix.buffer); 180 free (V2[0].buffer); 181 } 182 if (V3[0].type == ST_MATRIX_TMP) { 183 free (V3[0].buffer[0].header.buffer); 184 free (V3[0].buffer[0].matrix.buffer); 185 free (V3[0].buffer); 186 } 187 188 /* at the end, V1 and V2 are deleted only if they were temporary */ 189 190 clear_stack (V1); 191 clear_stack (V2); 192 clear_stack (V3); 193 return (TRUE); 194 195 } 196 197 // XXX we temporarily drop the concept of using one of the temporary input vectors for 198 // the output vector (thus saving an ALLOC): we have to juggle the size of the input vectors 199 // as well as their temporary state 200 201 int VV_binary (StackVar *OUT, StackVar *V1, StackVar *V2, char *op) { 202 203 int i, Nx; 204 char line[512]; // this is only used to report an error 205 206 // the vectors have to match in length 207 if (V1[0].vector[0].Nelements != V2[0].vector[0].Nelements) { 208 return (FALSE); 209 } 210 211 Nx = V1[0].vector[0].Nelements; 212 213 // create the output vector guaranteed to be temporary until the very end 214 OUT[0].vector = InitVector (); 215 OUT[0].type = ST_VECTOR_TMP; 27 216 28 217 // set up the possible operations : int OP int -> int, all else yield float … … 59 248 break; \ 60 249 } \ 61 if ((FTYPE == 'S') && (V1->vector->type != OPIHI_FLT) && (V2->vector->type != OPIHI_FLT)) { \250 if ((FTYPE == ST_SCALAR_FLT) && (V1->vector->type != OPIHI_FLT) && (V2->vector->type != OPIHI_FLT)) { \ 62 251 MatchVector (OUT[0].vector, V1[0].vector, OPIHI_FLT); \ 63 252 opihi_int *M1 = V1[0].vector[0].elements.Int; \ … … 82 271 83 272 switch (op[0]) { 84 case '+': VV_FUNC('s', *M1 + *M2); 85 case '-': VV_FUNC('s', *M1 - *M2); 86 case '*': VV_FUNC('s', *M1 * *M2); 87 case '/': VV_FUNC('S', *M1 / (opihi_flt) *M2); 88 case '%': VV_FUNC('s', (long long)*M1 % (long long)*M2); 89 case '^': VV_FUNC('S', pow (*M1, *M2)); 90 case '@': VV_FUNC('S', DEG_RAD*atan2 (*M1, *M2)); 91 case 'D': VV_FUNC('s', MIN (*M1, *M2)); 92 case 'U': VV_FUNC('s', MAX (*M1, *M2)); 93 case '<': VV_FUNC('s', (*M1 < *M2) ? 1 : 0); 94 case '>': VV_FUNC('s', (*M1 > *M2) ? 1 : 0); 95 case '&': VV_FUNC('s', ((long long)*M1 & (long long)*M2)); 96 case '|': VV_FUNC('s', ((long long)*M1 | (long long)*M2)); 97 case 'E': VV_FUNC('s', (*M1 == *M2) ? 1 : 0); 98 case 'N': VV_FUNC('s', (*M1 != *M2) ? 1 : 0); 99 case 'L': VV_FUNC('s', (*M1 <= *M2) ? 1 : 0); 100 case 'G': VV_FUNC('s', (*M1 >= *M2) ? 1 : 0); 101 case 'A': VV_FUNC('s', (*M1 && *M2) ? 1 : 0); 102 case 'O': VV_FUNC('s', (*M1 || *M2) ? 1 : 0); 273 case '+': VV_FUNC(ST_SCALAR_INT, *M1 + *M2); 274 case '-': VV_FUNC(ST_SCALAR_INT, *M1 - *M2); 275 case '*': VV_FUNC(ST_SCALAR_INT, *M1 * *M2); 276 case '/': VV_FUNC(ST_SCALAR_FLT, *M1 / (opihi_flt) *M2); 277 case '%': VV_FUNC(ST_SCALAR_INT, (long long)*M1 % (long long)*M2); 278 case '^': VV_FUNC(ST_SCALAR_FLT, pow (*M1, *M2)); 279 case '@': VV_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (*M1, *M2)); 280 case 'a': VV_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (*M1, *M2)); 281 case 'D': VV_FUNC(ST_SCALAR_INT, MIN (*M1, *M2)); 282 case 'U': VV_FUNC(ST_SCALAR_INT, MAX (*M1, *M2)); 283 case '<': VV_FUNC(ST_SCALAR_INT, (*M1 < *M2) ? 1 : 0); 284 case '>': VV_FUNC(ST_SCALAR_INT, (*M1 > *M2) ? 1 : 0); 285 case '&': VV_FUNC(ST_SCALAR_INT, ((long long)*M1 & (long long)*M2)); 286 case '|': VV_FUNC(ST_SCALAR_INT, ((long long)*M1 | (long long)*M2)); 287 case 'E': VV_FUNC(ST_SCALAR_INT, (*M1 == *M2) ? 1 : 0); 288 case 'N': VV_FUNC(ST_SCALAR_INT, (*M1 != *M2) ? 1 : 0); 289 case 'L': VV_FUNC(ST_SCALAR_INT, (*M1 <= *M2) ? 1 : 0); 290 case 'G': VV_FUNC(ST_SCALAR_INT, (*M1 >= *M2) ? 1 : 0); 291 case 'A': VV_FUNC(ST_SCALAR_INT, (*M1 && *M2) ? 1 : 0); 292 case 'O': VV_FUNC(ST_SCALAR_INT, (*M1 || *M2) ? 1 : 0); 103 293 default: 104 s printf (line, "error: op %c not defined!", op[0]);294 snprintf (line, 512, "error: op %c not defined!", op[0]); 105 295 push_error (line); 106 296 return (FALSE); … … 110 300 /** free up any temporary buffers: **/ 111 301 112 if (V1[0].type == 'v') {302 if (V1[0].type == ST_VECTOR_TMP) { 113 303 free (V1[0].vector[0].elements.Ptr); 114 304 free (V1[0].vector); 115 305 } 116 if (V2[0].type == 'v') {306 if (V2[0].type == ST_VECTOR_TMP) { 117 307 free (V2[0].vector[0].elements.Ptr); 118 308 free (V2[0].vector); … … 134 324 135 325 OUT[0].vector = InitVector (); 136 OUT[0].type = 'v'; /*** <<--- says this is a temporary matrix ***/326 OUT[0].type = ST_VECTOR_TMP; /*** <<--- says this is a temporary matrix ***/ 137 327 138 328 // set up the possible operations : int OP int -> int, all else yield float 139 329 // OP is the operation performed on *M1 and *M2 140 330 # define SV_FUNC(FTYPE,OP) { \ 141 if ((V1->type == 'S') && (V2->vector->type == OPIHI_FLT)) { \331 if ((V1->type == ST_SCALAR_FLT) && (V2->vector->type == OPIHI_FLT)) { \ 142 332 CopyVector (OUT[0].vector, V2[0].vector); \ 143 333 opihi_flt M1 = V1[0].FltValue; \ … … 149 339 break; \ 150 340 } \ 151 if ((V1->type == 'S') && (V2->vector->type != OPIHI_FLT)) { \341 if ((V1->type == ST_SCALAR_FLT) && (V2->vector->type != OPIHI_FLT)) { \ 152 342 MatchVector (OUT[0].vector, V2[0].vector, OPIHI_FLT); \ 153 343 opihi_flt M1 = V1[0].FltValue; \ … … 159 349 break; \ 160 350 } \ 161 if ((V1->type == 's') && (V2->vector->type == OPIHI_FLT)) { \351 if ((V1->type == ST_SCALAR_INT) && (V2->vector->type == OPIHI_FLT)) { \ 162 352 CopyVector (OUT[0].vector, V2[0].vector); \ 163 353 opihi_int M1 = V1[0].IntValue; \ … … 169 359 break; \ 170 360 } \ 171 if ((FTYPE == 'S') && (V1->type == 's') && (V2->vector->type != OPIHI_FLT)) { \361 if ((FTYPE == ST_SCALAR_FLT) && (V1->type == ST_SCALAR_INT) && (V2->vector->type != OPIHI_FLT)) { \ 172 362 MatchVector (OUT[0].vector, V2[0].vector, OPIHI_FLT); \ 173 363 opihi_int M1 = V1[0].IntValue; \ … … 179 369 break; \ 180 370 } \ 181 if ((V1->type == 's') && (V2->vector->type != OPIHI_FLT)) { \371 if ((V1->type == ST_SCALAR_INT) && (V2->vector->type != OPIHI_FLT)) { \ 182 372 CopyVector (OUT[0].vector, V2[0].vector); \ 183 373 opihi_int M1 = V1[0].IntValue; \ … … 192 382 193 383 switch (op[0]) { 194 case '+': SV_FUNC('s', M1 + *M2); 195 case '-': SV_FUNC('s', M1 - *M2); 196 case '*': SV_FUNC('s', M1 * *M2); 197 case '/': SV_FUNC('S', M1 / (opihi_flt) *M2); 198 case '%': SV_FUNC('s', (long long) M1 % (long long) *M2); 199 case '^': SV_FUNC('S', pow (M1, *M2)); 200 case '@': SV_FUNC('S', DEG_RAD*atan2 (M1, *M2)); 201 case 'D': SV_FUNC('s', MIN (M1, *M2)); 202 case 'U': SV_FUNC('s', MAX (M1, *M2)); 203 case '<': SV_FUNC('s', (M1 < *M2) ? 1 : 0); 204 case '>': SV_FUNC('s', (M1 > *M2) ? 1 : 0); 205 case '&': SV_FUNC('s', ((long long)M1 & (long long)*M2)); 206 case '|': SV_FUNC('s', ((long long)M1 | (long long)*M2)); 207 case 'E': SV_FUNC('s', (M1 == *M2) ? 1 : 0); 208 case 'N': SV_FUNC('s', (M1 != *M2) ? 1 : 0); 209 case 'L': SV_FUNC('s', (M1 <= *M2) ? 1 : 0); 210 case 'G': SV_FUNC('s', (M1 >= *M2) ? 1 : 0); 211 case 'A': SV_FUNC('s', (M1 && *M2) ? 1 : 0); 212 case 'O': SV_FUNC('s', (M1 || *M2) ? 1 : 0); 384 case '+': SV_FUNC(ST_SCALAR_INT, M1 + *M2); 385 case '-': SV_FUNC(ST_SCALAR_INT, M1 - *M2); 386 case '*': SV_FUNC(ST_SCALAR_INT, M1 * *M2); 387 case '/': SV_FUNC(ST_SCALAR_FLT, M1 / (opihi_flt) *M2); 388 case '%': SV_FUNC(ST_SCALAR_INT, (long long) M1 % (long long) *M2); 389 case '^': SV_FUNC(ST_SCALAR_FLT, pow (M1, *M2)); 390 case '@': SV_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, *M2)); 391 case 'a': SV_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, *M2)); 392 case 'D': SV_FUNC(ST_SCALAR_INT, MIN (M1, *M2)); 393 case 'U': SV_FUNC(ST_SCALAR_INT, MAX (M1, *M2)); 394 case '<': SV_FUNC(ST_SCALAR_INT, (M1 < *M2) ? 1 : 0); 395 case '>': SV_FUNC(ST_SCALAR_INT, (M1 > *M2) ? 1 : 0); 396 case '&': SV_FUNC(ST_SCALAR_INT, ((long long)M1 & (long long)*M2)); 397 case '|': SV_FUNC(ST_SCALAR_INT, ((long long)M1 | (long long)*M2)); 398 case 'E': SV_FUNC(ST_SCALAR_INT, (M1 == *M2) ? 1 : 0); 399 case 'N': SV_FUNC(ST_SCALAR_INT, (M1 != *M2) ? 1 : 0); 400 case 'L': SV_FUNC(ST_SCALAR_INT, (M1 <= *M2) ? 1 : 0); 401 case 'G': SV_FUNC(ST_SCALAR_INT, (M1 >= *M2) ? 1 : 0); 402 case 'A': SV_FUNC(ST_SCALAR_INT, (M1 && *M2) ? 1 : 0); 403 case 'O': SV_FUNC(ST_SCALAR_INT, (M1 || *M2) ? 1 : 0); 213 404 default: 214 s printf (line, "error: op %c not defined!", op[0]);405 snprintf (line, 512, "error: op %c not defined!", op[0]); 215 406 push_error (line); 216 407 return (FALSE); … … 219 410 220 411 /** free up any temporary buffers: **/ 221 if (V2[0].type == 'v') {412 if (V2[0].type == ST_VECTOR_TMP) { 222 413 free (V2[0].vector[0].elements.Ptr); 223 414 free (V2[0].vector); … … 240 431 241 432 OUT[0].vector = InitVector (); 242 OUT[0].type = 'v'; /*** <<--- says this is a temporary matrix ***/433 OUT[0].type = ST_VECTOR_TMP; /*** <<--- says this is a temporary matrix ***/ 243 434 244 435 // set up the possible operations : int OP int -> int, all else yield float 245 436 // OP is the operation performed on *M1 and *M2 246 437 # define VS_FUNC(FTYPE,OP) { \ 247 if ((V2->type == 'S') && (V1->vector->type == OPIHI_FLT)) { \438 if ((V2->type == ST_SCALAR_FLT) && (V1->vector->type == OPIHI_FLT)) { \ 248 439 CopyVector (OUT[0].vector, V1[0].vector); \ 249 440 opihi_flt *M1 = V1[0].vector[0].elements.Flt; \ … … 255 446 break; \ 256 447 } \ 257 if ((V2->type == 'S') && (V1->vector->type != OPIHI_FLT)) { \448 if ((V2->type == ST_SCALAR_FLT) && (V1->vector->type != OPIHI_FLT)) { \ 258 449 MatchVector (OUT[0].vector, V1[0].vector, OPIHI_FLT); \ 259 450 opihi_int *M1 = V1[0].vector[0].elements.Int; \ … … 265 456 break; \ 266 457 } \ 267 if ((V2->type == 's') && (V1->vector->type == OPIHI_FLT)) { \458 if ((V2->type == ST_SCALAR_INT) && (V1->vector->type == OPIHI_FLT)) { \ 268 459 CopyVector (OUT[0].vector, V1[0].vector); \ 269 460 opihi_flt *M1 = V1[0].vector[0].elements.Flt; \ … … 275 466 break; \ 276 467 } \ 277 if ((FTYPE == 'S') && (V2->type == 's') && (V1->vector->type != OPIHI_FLT)) { \468 if ((FTYPE == ST_SCALAR_FLT) && (V2->type == ST_SCALAR_INT) && (V1->vector->type != OPIHI_FLT)) { \ 278 469 CopyVector (OUT[0].vector, V1[0].vector); \ 279 470 opihi_int *M1 = V1[0].vector[0].elements.Int; \ … … 285 476 break; \ 286 477 } \ 287 if ((V2->type == 's') && (V1->vector->type != OPIHI_FLT)) { \478 if ((V2->type == ST_SCALAR_INT) && (V1->vector->type != OPIHI_FLT)) { \ 288 479 CopyVector (OUT[0].vector, V1[0].vector); \ 289 480 opihi_int *M1 = V1[0].vector[0].elements.Int; \ … … 298 489 299 490 switch (op[0]) { 300 case '+': VS_FUNC('s', *M1 + M2); 301 case '-': VS_FUNC('s', *M1 - M2); 302 case '*': VS_FUNC('s', *M1 * M2); 303 case '/': VS_FUNC('S', *M1 / (opihi_flt) M2); 304 case '%': VS_FUNC('s', (long long) *M1 % (long long) M2); 305 case '^': VS_FUNC('S', pow (*M1, M2)); 306 case '@': VS_FUNC('S', DEG_RAD*atan2 (*M1, M2)); 307 case 'D': VS_FUNC('s', MIN (*M1, M2)); 308 case 'U': VS_FUNC('s', MAX (*M1, M2)); 309 case '<': VS_FUNC('s', (*M1 < M2) ? 1 : 0); 310 case '>': VS_FUNC('s', (*M1 > M2) ? 1 : 0); 311 case '&': VS_FUNC('s', ((long long)*M1 & (long long)M2)); 312 case '|': VS_FUNC('s', ((long long)*M1 | (long long)M2)); 313 case 'E': VS_FUNC('s', (*M1 == M2) ? 1 : 0); 314 case 'N': VS_FUNC('s', (*M1 != M2) ? 1 : 0); 315 case 'L': VS_FUNC('s', (*M1 <= M2) ? 1 : 0); 316 case 'G': VS_FUNC('s', (*M1 >= M2) ? 1 : 0); 317 case 'A': VS_FUNC('s', (*M1 && M2) ? 1 : 0); 318 case 'O': VS_FUNC('s', (*M1 || M2) ? 1 : 0); 491 case '+': VS_FUNC(ST_SCALAR_INT, *M1 + M2); 492 case '-': VS_FUNC(ST_SCALAR_INT, *M1 - M2); 493 case '*': VS_FUNC(ST_SCALAR_INT, *M1 * M2); 494 case '/': VS_FUNC(ST_SCALAR_FLT, *M1 / (opihi_flt) M2); 495 case '%': VS_FUNC(ST_SCALAR_INT, (long long) *M1 % (long long) M2); 496 case '^': VS_FUNC(ST_SCALAR_FLT, pow (*M1, M2)); 497 case '@': VS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (*M1, M2)); 498 case 'a': VS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (*M1, M2)); 499 case 'D': VS_FUNC(ST_SCALAR_INT, MIN (*M1, M2)); 500 case 'U': VS_FUNC(ST_SCALAR_INT, MAX (*M1, M2)); 501 case '<': VS_FUNC(ST_SCALAR_INT, (*M1 < M2) ? 1 : 0); 502 case '>': VS_FUNC(ST_SCALAR_INT, (*M1 > M2) ? 1 : 0); 503 case '&': VS_FUNC(ST_SCALAR_INT, ((long long)*M1 & (long long)M2)); 504 case '|': VS_FUNC(ST_SCALAR_INT, ((long long)*M1 | (long long)M2)); 505 case 'E': VS_FUNC(ST_SCALAR_INT, (*M1 == M2) ? 1 : 0); 506 case 'N': VS_FUNC(ST_SCALAR_INT, (*M1 != M2) ? 1 : 0); 507 case 'L': VS_FUNC(ST_SCALAR_INT, (*M1 <= M2) ? 1 : 0); 508 case 'G': VS_FUNC(ST_SCALAR_INT, (*M1 >= M2) ? 1 : 0); 509 case 'A': VS_FUNC(ST_SCALAR_INT, (*M1 && M2) ? 1 : 0); 510 case 'O': VS_FUNC(ST_SCALAR_INT, (*M1 || M2) ? 1 : 0); 319 511 default: 320 s printf (line, "error: op %c not defined!", op[0]);512 snprintf (line, 512, "error: op %c not defined!", op[0]); 321 513 push_error (line); 322 514 return (FALSE); … … 326 518 /** free up any temporary buffers: **/ 327 519 328 if (V1[0].type == 'v') {520 if (V1[0].type == ST_VECTOR_TMP) { 329 521 free (V1[0].vector[0].elements.Ptr); 330 522 free (V1[0].vector); … … 353 545 354 546 /* if possible, use V1 as temp buffer, otherwise create new one */ 355 if (V1[0].type == 'm') {547 if (V1[0].type == ST_MATRIX_TMP) { 356 548 OUT[0].buffer = V1[0].buffer; 357 V1[0].type = 'M'; /* prevent it from being freed below */549 V1[0].type = ST_MATRIX; /* prevent it from being freed below */ 358 550 } else { 359 551 /* do buffer.matrix.buffer and buffer.header.buffer get correctly zeroed? */ … … 361 553 CopyBuffer (OUT[0].buffer, V1[0].buffer); 362 554 } 363 OUT[0].type = 'm'; /*** <<--- says this is a temporary matrix ***/555 OUT[0].type = ST_MATRIX_TMP; /*** <<--- says this is a temporary matrix ***/ 364 556 365 557 float *M1 = (float *) V1[0].buffer[0].matrix.buffer; … … 395 587 case '^': MV_FUNC(pow (*M1, *M2)); 396 588 case '@': MV_FUNC(DEG_RAD*atan2 (*M1, *M2)); 589 case 'a': MV_FUNC(DEG_RAD*atan2 (*M1, *M2)); 397 590 case 'D': MV_FUNC(MIN (*M1, *M2)); 398 591 case 'U': MV_FUNC(MAX (*M1, *M2)); … … 408 601 case 'O': MV_FUNC((*M1 || *M2) ? 1 : 0); 409 602 default: 410 s printf (line, "error: op %c not defined!", op[0]);603 snprintf (line, 512, "error: op %c not defined!", op[0]); 411 604 push_error (line); 412 605 return (FALSE); … … 416 609 /** free up any temporary buffers: **/ 417 610 418 if (V1[0].type == 'm') {611 if (V1[0].type == ST_MATRIX_TMP) { 419 612 free (V1[0].buffer[0].header.buffer); 420 613 free (V1[0].buffer[0].matrix.buffer); 421 614 free (V1[0].buffer); 422 615 } 423 if (V2[0].type == 'v') {616 if (V2[0].type == ST_VECTOR_TMP) { 424 617 free (V2[0].vector[0].elements.Ptr); 425 618 free (V2[0].vector); … … 446 639 447 640 /* if possible, use V2 as temp buffer, otherwise create new one */ 448 if (V2[0].type == 'm') {641 if (V2[0].type == ST_MATRIX_TMP) { 449 642 OUT[0].buffer = V2[0].buffer; 450 V2[0].type = 'M'; /* prevent it from being freed below */643 V2[0].type = ST_MATRIX; /* prevent it from being freed below */ 451 644 } else { /* no spare temp buffer */ 452 645 OUT[0].buffer = InitBuffer (); 453 646 CopyBuffer (OUT[0].buffer, V2[0].buffer); 454 647 } 455 OUT[0].type = 'm'; /*** <<--- says this is a temporary matrix ***/648 OUT[0].type = ST_MATRIX_TMP; /*** <<--- says this is a temporary matrix ***/ 456 649 457 650 float *M2 = (float *) V2[0].buffer[0].matrix.buffer; … … 487 680 case '^': VM_FUNC(pow (*M1, *M2)); 488 681 case '@': VM_FUNC(DEG_RAD*atan2 (*M1, *M2)); 682 case 'a': VM_FUNC(DEG_RAD*atan2 (*M1, *M2)); 489 683 case 'D': VM_FUNC(MIN (*M1, *M2)); 490 684 case 'U': VM_FUNC(MAX (*M1, *M2)); … … 500 694 case 'O': VM_FUNC((*M1 || *M2) ? 1 : 0); 501 695 default: 502 s printf (line, "error: op %c not defined!", op[0]);696 snprintf (line, 512, "error: op %c not defined!", op[0]); 503 697 push_error (line); 504 698 return (FALSE); … … 508 702 /** free up any temporary buffers: **/ 509 703 510 if (V1[0].type == 'v') {704 if (V1[0].type == ST_VECTOR_TMP) { 511 705 free (V1[0].vector[0].elements.Ptr); 512 706 free (V1[0].vector); 513 707 } 514 if (V2[0].type == 'm') {708 if (V2[0].type == ST_MATRIX_TMP) { 515 709 free (V2[0].buffer[0].header.buffer); 516 710 free (V2[0].buffer[0].matrix.buffer); … … 535 729 Ny = V1[0].buffer[0].matrix.Naxis[1]; 536 730 537 if (V1[0].type == 'm') { /** use V1 as temp buffer **/731 if (V1[0].type == ST_MATRIX_TMP) { /** use V1 as temp buffer **/ 538 732 OUT[0].buffer = V1[0].buffer; 539 V1[0].type = 'M'; /* prevent it from being freed below */733 V1[0].type = ST_MATRIX; /* prevent it from being freed below */ 540 734 } else { 541 if (V2[0].type == 'm') { /** use V2 as temp buffer, but header of V1 **/735 if (V2[0].type == ST_MATRIX_TMP) { /** use V2 as temp buffer, but header of V1 **/ 542 736 OUT[0].buffer = V2[0].buffer; 543 V2[0].type = 'M'; /* prevent it from being freed below */737 V2[0].type = ST_MATRIX; /* prevent it from being freed below */ 544 738 } else { /* no spare temp buffer */ 545 739 OUT[0].buffer = InitBuffer (); … … 547 741 } 548 742 } 549 OUT[0].type = 'm'; /*** <<--- says this is a temporary matrix ***/743 OUT[0].type = ST_MATRIX_TMP; /*** <<--- says this is a temporary matrix ***/ 550 744 551 745 M1 = (float *)V1[0].buffer[0].matrix.buffer; … … 567 761 case '^': MM_FUNC(pow (*M1, *M2)); 568 762 case '@': MM_FUNC(DEG_RAD*atan2 (*M1, *M2)); 763 case 'a': MM_FUNC(DEG_RAD*atan2 (*M1, *M2)); 569 764 case 'D': MM_FUNC(MIN (*M1, *M2)); 570 765 case 'U': MM_FUNC(MAX (*M1, *M2)); … … 580 775 case 'O': MM_FUNC((*M1 || *M2) ? 1 : 0); 581 776 default: 582 s printf (line, "error: op %c not defined!", op[0]);777 snprintf (line, 512, "error: op %c not defined!", op[0]); 583 778 push_error (line); 584 779 return (FALSE); … … 588 783 /** free up any temporary buffers: **/ 589 784 590 if (V1[0].type == 'm') {785 if (V1[0].type == ST_MATRIX_TMP) { 591 786 free (V1[0].buffer[0].header.buffer); 592 787 free (V1[0].buffer[0].matrix.buffer); 593 788 free (V1[0].buffer); 594 789 } 595 if (V2[0].type == 'm') {790 if (V2[0].type == ST_MATRIX_TMP) { 596 791 free (V2[0].buffer[0].header.buffer); 597 792 free (V2[0].buffer[0].matrix.buffer); … … 615 810 616 811 /* if possible, use V1 as temp buffer, otherwise create new one */ 617 if (V1[0].type == 'm') {812 if (V1[0].type == ST_MATRIX_TMP) { 618 813 OUT[0].buffer = V1[0].buffer; 619 V1[0].type = 'M'; /* prevent it from being freed below */814 V1[0].type = ST_MATRIX; /* prevent it from being freed below */ 620 815 } else { 621 816 OUT[0].buffer = InitBuffer (); 622 817 CopyBuffer (OUT[0].buffer, V1[0].buffer); 623 818 } 624 OUT[0].type = 'm'; /*** <<--- says this is a temporary matrix ***/819 OUT[0].type = ST_MATRIX_TMP; /*** <<--- says this is a temporary matrix ***/ 625 820 626 821 float *M1 = (float *)V1[0].buffer[0].matrix.buffer; … … 628 823 629 824 # define MS_FUNC(OP) { \ 630 if (V2->type == 'S') { \825 if (V2->type == ST_SCALAR_FLT) { \ 631 826 opihi_flt M2 = V2[0].FltValue; \ 632 827 for (i = 0; i < Nx*Ny; i++, out++, M1++) { \ … … 635 830 break; \ 636 831 } \ 637 if (V2->type == 's') { \832 if (V2->type == ST_SCALAR_INT) { \ 638 833 opihi_int M2 = V2[0].IntValue; \ 639 834 for (i = 0; i < Nx*Ny; i++, out++, M1++) { \ … … 652 847 case '^': MS_FUNC(pow (*M1, M2)); 653 848 case '@': MS_FUNC(DEG_RAD*atan2 (*M1, M2)); 849 case 'a': MS_FUNC(DEG_RAD*atan2 (*M1, M2)); 654 850 case 'D': MS_FUNC(MIN (*M1, M2)); 655 851 case 'U': MS_FUNC(MAX (*M1, M2)); … … 665 861 case 'O': MS_FUNC((*M1 || M2) ? 1 : 0); 666 862 default: 667 s printf (line, "error: op %c not defined!", op[0]);863 snprintf (line, 512, "error: op %c not defined!", op[0]); 668 864 push_error (line); 669 865 return (FALSE); … … 671 867 # undef MS_FUNC 672 868 673 if (V1[0].type == 'm') {869 if (V1[0].type == ST_MATRIX_TMP) { 674 870 free (V1[0].buffer[0].header.buffer); 675 871 free (V1[0].buffer[0].matrix.buffer); … … 691 887 Ny = V2[0].buffer[0].matrix.Naxis[1]; 692 888 693 if (V2[0].type == 'm') { /* V2[0] is NOT temporary, we can't use it for storage */889 if (V2[0].type == ST_MATRIX_TMP) { /* V2[0] is NOT temporary, we can't use it for storage */ 694 890 OUT[0].buffer = V2[0].buffer; 695 V2[0].type = 'M'; /* prevent it from being freed below */891 V2[0].type = ST_MATRIX; /* prevent it from being freed below */ 696 892 } else { 697 893 OUT[0].buffer = InitBuffer (); 698 894 CopyBuffer (OUT[0].buffer, V2[0].buffer); 699 895 } 700 OUT[0].type = 'm'; /*** <<--- says this is a temporary matrix ***/896 OUT[0].type = ST_MATRIX_TMP; /*** <<--- says this is a temporary matrix ***/ 701 897 702 898 float *M2 = (float *)V2[0].buffer[0].matrix.buffer; … … 704 900 705 901 # define SM_FUNC(OP) { \ 706 if (V1->type == 'S') { \902 if (V1->type == ST_SCALAR_FLT) { \ 707 903 opihi_flt M1 = V1[0].FltValue; \ 708 904 for (i = 0; i < Nx*Ny; i++, out++, M2++) { \ … … 711 907 break; \ 712 908 } \ 713 if (V1->type == 's') { \909 if (V1->type == ST_SCALAR_INT) { \ 714 910 opihi_int M1 = V1[0].IntValue; \ 715 911 for (i = 0; i < Nx*Ny; i++, out++, M2++) { \ … … 728 924 case '^': SM_FUNC(pow (M1, *M2)); 729 925 case '@': SM_FUNC(DEG_RAD*atan2 (M1, *M2)); 926 case 'a': SM_FUNC(DEG_RAD*atan2 (M1, *M2)); 730 927 case 'D': SM_FUNC(MIN (M1, *M2)); 731 928 case 'U': SM_FUNC(MAX (M1, *M2)); … … 741 938 case 'O': SM_FUNC((M1 || *M2) ? 1 : 0); 742 939 default: 743 s printf (line, "error: op %c not defined!", op[0]);940 snprintf (line, 512, "error: op %c not defined!", op[0]); 744 941 push_error (line); 745 942 return (FALSE); … … 747 944 # undef SM_FUNC 748 945 749 if (V2[0].type == 'm') {946 if (V2[0].type == ST_MATRIX_TMP) { 750 947 free (V2[0].buffer[0].header.buffer); 751 948 free (V2[0].buffer[0].matrix.buffer); … … 764 961 765 962 # define SS_FUNC(FTYPE,OP) { \ 766 if ((V1->type == 'S') && (V2->type == 'S')) { \963 if ((V1->type == ST_SCALAR_FLT) && (V2->type == ST_SCALAR_FLT)) { \ 767 964 opihi_flt M1 = V1[0].FltValue; \ 768 965 opihi_flt M2 = V2[0].FltValue; \ 769 OUT[0].type = 'S'; \966 OUT[0].type = ST_SCALAR_FLT; \ 770 967 OUT[0].FltValue = OP; \ 771 968 break; \ 772 969 } \ 773 if ((V1->type == 'S') && (V2->type == 's')) { \970 if ((V1->type == ST_SCALAR_FLT) && (V2->type == ST_SCALAR_INT)) { \ 774 971 opihi_flt M1 = V1[0].FltValue; \ 775 972 opihi_int M2 = V2[0].IntValue; \ 776 OUT[0].type = 'S'; \973 OUT[0].type = ST_SCALAR_FLT; \ 777 974 OUT[0].FltValue = OP; \ 778 975 break; \ 779 976 } \ 780 if ((V1->type == 's') && (V2->type == 'S')) { \977 if ((V1->type == ST_SCALAR_INT) && (V2->type == ST_SCALAR_FLT)) { \ 781 978 opihi_int M1 = V1[0].IntValue; \ 782 979 opihi_flt M2 = V2[0].FltValue; \ 783 OUT[0].type = 'S'; \980 OUT[0].type = ST_SCALAR_FLT; \ 784 981 OUT[0].FltValue = OP; \ 785 982 break; \ 786 983 } \ 787 if ((FTYPE == 'S') && (V1->type == 's') && (V2->type == 's')) { \984 if ((FTYPE == ST_SCALAR_FLT) && (V1->type == ST_SCALAR_INT) && (V2->type == ST_SCALAR_INT)) { \ 788 985 opihi_int M1 = V1[0].IntValue; \ 789 986 opihi_int M2 = V2[0].IntValue; \ 790 OUT[0].type = 'S'; \987 OUT[0].type = ST_SCALAR_FLT; \ 791 988 OUT[0].FltValue = OP; \ 792 989 break; \ 793 990 } \ 794 if ((V1->type == 's') && (V2->type == 's')) { \991 if ((V1->type == ST_SCALAR_INT) && (V2->type == ST_SCALAR_INT)) { \ 795 992 opihi_int M1 = V1[0].IntValue; \ 796 993 opihi_int M2 = V2[0].IntValue; \ 797 OUT[0].type = 's'; \994 OUT[0].type = ST_SCALAR_INT; \ 798 995 OUT[0].IntValue = OP; \ 799 996 break; \ … … 802 999 803 1000 switch (op[0]) { 804 case '+': SS_FUNC('s', M1 + M2); 805 case '-': SS_FUNC('s', M1 - M2); 806 case '*': SS_FUNC('s', M1 * M2); 807 case '/': SS_FUNC('S', M1 / (opihi_flt) M2); 808 case '%': SS_FUNC('s', (long long) M1 % (long long) M2); 809 case '^': SS_FUNC('S', pow (M1, M2)); 810 case '@': SS_FUNC('S', DEG_RAD*atan2 (M1, M2)); 811 case 'D': SS_FUNC('s', MIN (M1, M2)); 812 case 'U': SS_FUNC('s', MAX (M1, M2)); 813 case '<': SS_FUNC('s', (M1 < M2) ? 1 : 0); 814 case '>': SS_FUNC('s', (M1 > M2) ? 1 : 0); 815 case '&': SS_FUNC('s', ((long long)M1 & (long long)M2)); 816 case '|': SS_FUNC('s', ((long long)M1 | (long long)M2)); 817 case 'E': SS_FUNC('s', (M1 == M2) ? 1 : 0); 818 case 'N': SS_FUNC('s', (M1 != M2) ? 1 : 0); 819 case 'L': SS_FUNC('s', (M1 <= M2) ? 1 : 0); 820 case 'G': SS_FUNC('s', (M1 >= M2) ? 1 : 0); 821 case 'A': SS_FUNC('s', (M1 && M2) ? 1 : 0); 822 case 'O': SS_FUNC('s', (M1 || M2) ? 1 : 0); 1001 case '+': SS_FUNC(ST_SCALAR_INT, M1 + M2); 1002 case '-': SS_FUNC(ST_SCALAR_INT, M1 - M2); 1003 case '*': SS_FUNC(ST_SCALAR_INT, M1 * M2); 1004 case '/': SS_FUNC(ST_SCALAR_FLT, M1 / (opihi_flt) M2); 1005 case '%': SS_FUNC(ST_SCALAR_INT, (long long) M1 % (long long) M2); 1006 case '^': SS_FUNC(ST_SCALAR_FLT, pow (M1, M2)); 1007 case '@': SS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, M2)); 1008 case 'a': SS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, M2)); 1009 case 'D': SS_FUNC(ST_SCALAR_INT, MIN (M1, M2)); 1010 case 'U': SS_FUNC(ST_SCALAR_INT, MAX (M1, M2)); 1011 case '<': SS_FUNC(ST_SCALAR_INT, (M1 < M2) ? 1 : 0); 1012 case '>': SS_FUNC(ST_SCALAR_INT, (M1 > M2) ? 1 : 0); 1013 case '&': SS_FUNC(ST_SCALAR_INT, ((long long)M1 & (long long)M2)); 1014 case '|': SS_FUNC(ST_SCALAR_INT, ((long long)M1 | (long long)M2)); 1015 case 'E': SS_FUNC(ST_SCALAR_INT, (M1 == M2) ? 1 : 0); 1016 case 'N': SS_FUNC(ST_SCALAR_INT, (M1 != M2) ? 1 : 0); 1017 case 'L': SS_FUNC(ST_SCALAR_INT, (M1 <= M2) ? 1 : 0); 1018 case 'G': SS_FUNC(ST_SCALAR_INT, (M1 >= M2) ? 1 : 0); 1019 case 'A': SS_FUNC(ST_SCALAR_INT, (M1 && M2) ? 1 : 0); 1020 case 'O': SS_FUNC(ST_SCALAR_INT, (M1 || M2) ? 1 : 0); 823 1021 default: 824 s printf (line, "error: op %c not defined!", op[0]);1022 snprintf (line, 512, "error: op %c not defined!", op[0]); 825 1023 push_error (line); 826 1024 return (FALSE); … … 844 1042 845 1043 if ((op[0] != 'N') && (op[0] != 'E')) { 846 s printf (line, "error: op %c not defined for string operations!", op[0]);1044 snprintf (line, 512, "error: op %c not defined for string operations!", op[0]); 847 1045 push_error (line); 848 1046 return (FALSE); … … 853 1051 thus: string == number -> false */ 854 1052 855 if ( !strncasecmp (&V1[0].type, "S", 1)) {1053 if (V1[0].type == ST_SCALAR_INT) { 856 1054 value = (op[0] == 'N'); 857 1055 goto escape; 858 1056 } 859 if (!strncasecmp (&V2[0].type, "S", 1)) { 1057 if (V1[0].type == ST_SCALAR_FLT) { 1058 value = (op[0] == 'N'); 1059 goto escape; 1060 } 1061 if (V2[0].type == ST_SCALAR_INT) { 1062 value = (op[0] == 'N'); 1063 goto escape; 1064 } 1065 if (V2[0].type == ST_SCALAR_FLT) { 860 1066 value = (op[0] == 'N'); 861 1067 goto escape; … … 870 1076 break; 871 1077 default: 872 s printf (line, "error: op %c not defined for string operations!", op[0]);1078 snprintf (line, 512, "error: op %c not defined for string operations!", op[0]); 873 1079 push_error (line); 874 1080 return (FALSE); … … 877 1083 escape: 878 1084 OUT[0].FltValue = value; 879 OUT[0].type = 'S';1085 OUT[0].type = ST_SCALAR_FLT; 880 1086 881 1087 clear_stack (V1); … … 891 1097 892 1098 # define S_FUNC(OP,FTYPE) { \ 893 if (V1->type == 'S') { \1099 if (V1->type == ST_SCALAR_FLT) { \ 894 1100 opihi_flt M1 = V1[0].FltValue; \ 895 OUT[0].type = 'S'; \1101 OUT[0].type = ST_SCALAR_FLT; \ 896 1102 OUT[0].FltValue = OP; \ 897 1103 clear_stack (V1); \ 898 1104 return (TRUE); \ 899 1105 } \ 900 if ((FTYPE == 'S') && (V1->type == 's')) { \1106 if ((FTYPE == ST_SCALAR_FLT) && (V1->type == ST_SCALAR_INT)) { \ 901 1107 opihi_int M1 = V1[0].IntValue; \ 902 OUT[0].type = 'S'; \1108 OUT[0].type = ST_SCALAR_FLT; \ 903 1109 OUT[0].FltValue = OP; \ 904 1110 clear_stack (V1); \ 905 1111 return (TRUE); \ 906 1112 } \ 907 if ((FTYPE == 's') && (V1->type == 's')) { \1113 if ((FTYPE == ST_SCALAR_INT) && (V1->type == ST_SCALAR_INT)) { \ 908 1114 opihi_int M1 = V1[0].IntValue; \ 909 OUT[0].type = 's'; \1115 OUT[0].type = ST_SCALAR_INT; \ 910 1116 OUT[0].IntValue = OP; \ 911 1117 clear_stack (V1); \ … … 914 1120 } 915 1121 916 if (!strcmp (op, "=")) S_FUNC(M1, 's'); 917 if (!strcmp (op, "abs")) S_FUNC(fabs(M1), 's'); 918 if (!strcmp (op, "int")) S_FUNC((long long)(M1), 's'); 919 if (!strcmp (op, "exp")) S_FUNC(exp (M1), 'S'); 920 if (!strcmp (op, "ten")) S_FUNC(pow (10.0,M1), 'S'); 921 if (!strcmp (op, "log")) S_FUNC(log10 (M1), 'S'); 922 if (!strcmp (op, "ln")) S_FUNC(log (M1), 'S'); 923 if (!strcmp (op, "sqrt")) S_FUNC(sqrt (M1), 'S'); 924 if (!strcmp (op, "erf")) S_FUNC(erf (M1), 'S'); 925 if (!strcmp (op, "sinh")) S_FUNC(sinh (M1), 'S'); 926 if (!strcmp (op, "cosh")) S_FUNC(cosh (M1), 'S'); 927 if (!strcmp (op, "asinh")) S_FUNC(asinh (M1), 'S'); 928 if (!strcmp (op, "acosh")) S_FUNC(acosh (M1), 'S'); 929 if (!strcmp (op, "lgamma")) S_FUNC(lgamma (M1), 'S'); 930 if (!strcmp (op, "sin")) S_FUNC(sin (M1), 'S'); 931 if (!strcmp (op, "cos")) S_FUNC(cos (M1), 'S'); 932 if (!strcmp (op, "tan")) S_FUNC(tan (M1), 'S'); 933 if (!strcmp (op, "dsin")) S_FUNC(sin (M1*RAD_DEG), 'S'); 934 if (!strcmp (op, "dcos")) S_FUNC(cos (M1*RAD_DEG), 'S'); 935 if (!strcmp (op, "dtan")) S_FUNC(tan (M1*RAD_DEG), 'S'); 936 if (!strcmp (op, "asin")) S_FUNC(asin (M1), 'S'); 937 if (!strcmp (op, "acos")) S_FUNC(acos (M1), 'S'); 938 if (!strcmp (op, "atan")) S_FUNC(atan (M1), 'S'); 939 if (!strcmp (op, "dasin")) S_FUNC(asin (M1)*DEG_RAD, 'S'); 940 if (!strcmp (op, "dacos")) S_FUNC(acos (M1)*DEG_RAD, 'S'); 941 if (!strcmp (op, "datan")) S_FUNC(atan (M1)*DEG_RAD, 'S'); 942 if (!strcmp (op, "rnd")) S_FUNC(M1*0.0 + drand48(), 'S'); 943 if (!strcmp (op, "not")) S_FUNC(!(M1), 's'); 944 if (!strcmp (op, "--")) S_FUNC(-1*M1, 's'); // NOTE: opihi_int is signed, 945 if (!strcmp (op, "isinf")) S_FUNC(!finite(M1), 'S'); // XXX modify in future 946 if (!strcmp (op, "isnan")) S_FUNC(isnan(M1), 'S'); // XXX modify in future 1122 if (!strcmp (op, "=")) S_FUNC(M1, ST_SCALAR_INT); 1123 if (!strcmp (op, "abs")) S_FUNC(fabs(M1), ST_SCALAR_INT); 1124 if (!strcmp (op, "int")) S_FUNC((long long)(M1), ST_SCALAR_INT); 1125 if (!strcmp (op, "floor")) S_FUNC(floor (M1), ST_SCALAR_FLT); 1126 if (!strcmp (op, "ceil")) S_FUNC(ceil (M1), ST_SCALAR_FLT); 1127 // if (!strcmp (op, "rint")) S_FUNC(nearbyint (M1), ST_SCALAR_FLT); 1128 if (!strcmp (op, "exp")) S_FUNC(exp (M1), ST_SCALAR_FLT); 1129 if (!strcmp (op, "ten")) S_FUNC(pow (10.0,M1), ST_SCALAR_FLT); 1130 if (!strcmp (op, "log")) S_FUNC(log10 (M1), ST_SCALAR_FLT); 1131 if (!strcmp (op, "ln")) S_FUNC(log (M1), ST_SCALAR_FLT); 1132 if (!strcmp (op, "sqrt")) S_FUNC(sqrt (M1), ST_SCALAR_FLT); 1133 if (!strcmp (op, "erf")) S_FUNC(erf (M1), ST_SCALAR_FLT); 1134 if (!strcmp (op, "sinh")) S_FUNC(sinh (M1), ST_SCALAR_FLT); 1135 if (!strcmp (op, "cosh")) S_FUNC(cosh (M1), ST_SCALAR_FLT); 1136 if (!strcmp (op, "asinh")) S_FUNC(asinh (M1), ST_SCALAR_FLT); 1137 if (!strcmp (op, "acosh")) S_FUNC(acosh (M1), ST_SCALAR_FLT); 1138 if (!strcmp (op, "lgamma")) S_FUNC(lgamma (M1), ST_SCALAR_FLT); 1139 if (!strcmp (op, "sin")) S_FUNC(sin (M1), ST_SCALAR_FLT); 1140 if (!strcmp (op, "cos")) S_FUNC(cos (M1), ST_SCALAR_FLT); 1141 if (!strcmp (op, "tan")) S_FUNC(tan (M1), ST_SCALAR_FLT); 1142 if (!strcmp (op, "dsin")) S_FUNC(sin (M1*RAD_DEG), ST_SCALAR_FLT); 1143 if (!strcmp (op, "dcos")) S_FUNC(cos (M1*RAD_DEG), ST_SCALAR_FLT); 1144 if (!strcmp (op, "dtan")) S_FUNC(tan (M1*RAD_DEG), ST_SCALAR_FLT); 1145 if (!strcmp (op, "asin")) S_FUNC(asin (M1), ST_SCALAR_FLT); 1146 if (!strcmp (op, "acos")) S_FUNC(acos (M1), ST_SCALAR_FLT); 1147 if (!strcmp (op, "atan")) S_FUNC(atan (M1), ST_SCALAR_FLT); 1148 if (!strcmp (op, "dasin")) S_FUNC(asin (M1)*DEG_RAD, ST_SCALAR_FLT); 1149 if (!strcmp (op, "dacos")) S_FUNC(acos (M1)*DEG_RAD, ST_SCALAR_FLT); 1150 if (!strcmp (op, "datan")) S_FUNC(atan (M1)*DEG_RAD, ST_SCALAR_FLT); 1151 if (!strcmp (op, "rnd")) S_FUNC(M1*0.0 + drand48(), ST_SCALAR_FLT); 1152 if (!strcmp (op, "not")) S_FUNC(!(M1), ST_SCALAR_INT); 1153 if (!strcmp (op, "--")) S_FUNC(-1*M1, ST_SCALAR_INT); // NOTE: opihi_int is signed, 1154 if (!strcmp (op, "isinf")) S_FUNC(!finite(M1), ST_SCALAR_FLT); // XXX modify in future 1155 if (!strcmp (op, "isnan")) S_FUNC(isnan(M1), ST_SCALAR_FLT); // XXX modify in future 947 1156 948 1157 # undef S_FUNC 949 1158 950 1159 clear_stack (V1); 951 s printf (line, "error: op %s not defined!", op);1160 snprintf (line, 512, "error: op %s not defined!", op); 952 1161 push_error (line); 953 1162 return (FALSE); … … 962 1171 963 1172 OUT[0].vector = InitVector (); 964 OUT[0].type = 'v'; /*** <<--- says this is a temporary matrix ***/1173 OUT[0].type = ST_VECTOR_TMP; /*** <<--- says this is a temporary matrix ***/ 965 1174 966 1175 # define V_FUNC(OP,FTYPE) { \ … … 974 1183 goto escape; \ 975 1184 } \ 976 if ((V1->vector->type == OPIHI_INT) && (FTYPE == 'S')) { \1185 if ((V1->vector->type == OPIHI_INT) && (FTYPE == ST_SCALAR_FLT)) { \ 977 1186 MatchVector (OUT[0].vector, V1[0].vector, OPIHI_FLT); \ 978 1187 opihi_int *M1 = V1[0].vector[0].elements.Int; \ … … 983 1192 goto escape; \ 984 1193 } \ 985 if ((V1->vector->type == OPIHI_INT) && (FTYPE == 's')) { \1194 if ((V1->vector->type == OPIHI_INT) && (FTYPE == ST_SCALAR_INT)) { \ 986 1195 CopyVector (OUT[0].vector, V1[0].vector); \ 987 1196 opihi_int *M1 = V1[0].vector[0].elements.Int; \ … … 993 1202 } } 994 1203 995 if (!strcmp (op, "=")) V_FUNC(*M1, 's'); 996 if (!strcmp (op, "abs")) V_FUNC(fabs(*M1), 's'); 997 if (!strcmp (op, "int")) V_FUNC((long long)(*M1), 's'); 998 if (!strcmp (op, "exp")) V_FUNC(exp(*M1), 'S'); 999 if (!strcmp (op, "ten")) V_FUNC(pow(10.0,*M1), 'S'); 1000 if (!strcmp (op, "log")) V_FUNC(log10(*M1), 'S'); 1001 if (!strcmp (op, "ln")) V_FUNC(log(*M1), 'S'); 1002 if (!strcmp (op, "sqrt")) V_FUNC(sqrt(*M1), 'S'); 1003 if (!strcmp (op, "erf")) V_FUNC(erf(*M1), 'S'); 1004 if (!strcmp (op, "sinh")) V_FUNC(sinh(*M1), 'S'); 1005 if (!strcmp (op, "cosh")) V_FUNC(cosh(*M1), 'S'); 1006 if (!strcmp (op, "asinh")) V_FUNC(asinh(*M1), 'S'); 1007 if (!strcmp (op, "acosh")) V_FUNC(acosh(*M1), 'S'); 1008 if (!strcmp (op, "lgamma")) V_FUNC(lgamma(*M1), 'S'); 1009 if (!strcmp (op, "sin")) V_FUNC(sin(*M1), 'S'); 1010 if (!strcmp (op, "cos")) V_FUNC(cos(*M1), 'S'); 1011 if (!strcmp (op, "tan")) V_FUNC(tan(*M1), 'S'); 1012 if (!strcmp (op, "dsin")) V_FUNC(sin(*M1*RAD_DEG), 'S'); 1013 if (!strcmp (op, "dcos")) V_FUNC(cos(*M1*RAD_DEG), 'S'); 1014 if (!strcmp (op, "dtan")) V_FUNC(tan(*M1*RAD_DEG), 'S'); 1015 if (!strcmp (op, "asin")) V_FUNC(asin(*M1), 'S'); 1016 if (!strcmp (op, "acos")) V_FUNC(acos(*M1), 'S'); 1017 if (!strcmp (op, "atan")) V_FUNC(atan(*M1), 'S'); 1018 if (!strcmp (op, "dasin")) V_FUNC(asin(*M1)*DEG_RAD, 'S'); 1019 if (!strcmp (op, "dacos")) V_FUNC(acos(*M1)*DEG_RAD, 'S'); 1020 if (!strcmp (op, "datan")) V_FUNC(atan(*M1)*DEG_RAD, 'S'); 1021 if (!strcmp (op, "rnd")) V_FUNC(drand48(), 'S'); 1022 if (!strcmp (op, "ramp")) V_FUNC(i, 's'); 1023 if (!strcmp (op, "zero")) V_FUNC(0, 's'); 1024 if (!strcmp (op, "not")) V_FUNC(!(*M1), 's'); 1025 if (!strcmp (op, "--")) V_FUNC(-1*(*M1), 's'); // NOTE: opihi_int is signed 1026 if (!strcmp (op, "isinf")) V_FUNC(!finite(*M1), 'S'); 1027 if (!strcmp (op, "isnan")) V_FUNC(isnan(*M1), 'S'); 1028 if (!strcmp (op, "xramp")) V_FUNC(i, 's'); 1029 if (!strcmp (op, "yramp")) V_FUNC(0, 's'); 1204 if (!strcmp (op, "=")) V_FUNC(*M1, ST_SCALAR_INT); 1205 if (!strcmp (op, "abs")) V_FUNC(fabs(*M1), ST_SCALAR_INT); 1206 if (!strcmp (op, "int")) V_FUNC((long long)(*M1), ST_SCALAR_INT); 1207 if (!strcmp (op, "floor")) V_FUNC(floor (*M1), ST_SCALAR_FLT); 1208 if (!strcmp (op, "ceil")) V_FUNC(ceil (*M1), ST_SCALAR_FLT); 1209 // if (!strcmp (op, "rint")) V_FUNC(nearbyint (*M1), ST_SCALAR_FLT); 1210 if (!strcmp (op, "exp")) V_FUNC(exp(*M1), ST_SCALAR_FLT); 1211 if (!strcmp (op, "ten")) V_FUNC(pow(10.0,*M1), ST_SCALAR_FLT); 1212 if (!strcmp (op, "log")) V_FUNC(log10(*M1), ST_SCALAR_FLT); 1213 if (!strcmp (op, "ln")) V_FUNC(log(*M1), ST_SCALAR_FLT); 1214 if (!strcmp (op, "sqrt")) V_FUNC(sqrt(*M1), ST_SCALAR_FLT); 1215 if (!strcmp (op, "erf")) V_FUNC(erf(*M1), ST_SCALAR_FLT); 1216 if (!strcmp (op, "sinh")) V_FUNC(sinh(*M1), ST_SCALAR_FLT); 1217 if (!strcmp (op, "cosh")) V_FUNC(cosh(*M1), ST_SCALAR_FLT); 1218 if (!strcmp (op, "asinh")) V_FUNC(asinh(*M1), ST_SCALAR_FLT); 1219 if (!strcmp (op, "acosh")) V_FUNC(acosh(*M1), ST_SCALAR_FLT); 1220 if (!strcmp (op, "lgamma")) V_FUNC(lgamma(*M1), ST_SCALAR_FLT); 1221 if (!strcmp (op, "sin")) V_FUNC(sin(*M1), ST_SCALAR_FLT); 1222 if (!strcmp (op, "cos")) V_FUNC(cos(*M1), ST_SCALAR_FLT); 1223 if (!strcmp (op, "tan")) V_FUNC(tan(*M1), ST_SCALAR_FLT); 1224 if (!strcmp (op, "dsin")) V_FUNC(sin(*M1*RAD_DEG), ST_SCALAR_FLT); 1225 if (!strcmp (op, "dcos")) V_FUNC(cos(*M1*RAD_DEG), ST_SCALAR_FLT); 1226 if (!strcmp (op, "dtan")) V_FUNC(tan(*M1*RAD_DEG), ST_SCALAR_FLT); 1227 if (!strcmp (op, "asin")) V_FUNC(asin(*M1), ST_SCALAR_FLT); 1228 if (!strcmp (op, "acos")) V_FUNC(acos(*M1), ST_SCALAR_FLT); 1229 if (!strcmp (op, "atan")) V_FUNC(atan(*M1), ST_SCALAR_FLT); 1230 if (!strcmp (op, "dasin")) V_FUNC(asin(*M1)*DEG_RAD, ST_SCALAR_FLT); 1231 if (!strcmp (op, "dacos")) V_FUNC(acos(*M1)*DEG_RAD, ST_SCALAR_FLT); 1232 if (!strcmp (op, "datan")) V_FUNC(atan(*M1)*DEG_RAD, ST_SCALAR_FLT); 1233 if (!strcmp (op, "rnd")) V_FUNC(drand48(), ST_SCALAR_FLT); 1234 if (!strcmp (op, "ramp")) V_FUNC(i, ST_SCALAR_INT); 1235 if (!strcmp (op, "zero")) V_FUNC(0, ST_SCALAR_INT); 1236 if (!strcmp (op, "not")) V_FUNC(!(*M1), ST_SCALAR_INT); 1237 if (!strcmp (op, "--")) V_FUNC(-1*(*M1), ST_SCALAR_INT); // NOTE: opihi_int is signed 1238 if (!strcmp (op, "isinf")) V_FUNC(!finite(*M1), ST_SCALAR_FLT); 1239 if (!strcmp (op, "isnan")) V_FUNC(isnan(*M1), ST_SCALAR_FLT); 1240 if (!strcmp (op, "xramp")) V_FUNC(i, ST_SCALAR_INT); 1241 if (!strcmp (op, "yramp")) V_FUNC(0, ST_SCALAR_INT); 1030 1242 /* xramp and yramp above only make sense for matrices. for vectors, xramp = ramp, yramp = zero */ 1031 1243 … … 1034 1246 escape: 1035 1247 1036 if (V1[0].type == 'v') {1248 if (V1[0].type == ST_VECTOR_TMP) { 1037 1249 free (V1[0].vector[0].elements.Ptr); 1038 1250 free (V1[0].vector); … … 1053 1265 Ny = V1[0].buffer[0].matrix.Naxis[1]; 1054 1266 1055 if (V1[0].type == 'm') {1267 if (V1[0].type == ST_MATRIX_TMP) { 1056 1268 OUT[0].buffer = V1[0].buffer; 1057 V1[0].type = 'M'; /* prevent it from being freed below */1269 V1[0].type = ST_MATRIX; /* prevent it from being freed below */ 1058 1270 } else { 1059 1271 OUT[0].buffer = InitBuffer (); 1060 1272 CopyBuffer (OUT[0].buffer, V1[0].buffer); 1061 1273 } 1062 OUT[0].type = 'm'; /*** <<--- says this is a temporary matrix ***/1274 OUT[0].type = ST_MATRIX_TMP; /*** <<--- says this is a temporary matrix ***/ 1063 1275 M1 = (float *) V1[0].buffer[0].matrix.buffer; 1064 1276 out = (float *)OUT[0].buffer[0].matrix.buffer; … … 1067 1279 if (!strcmp (op, "abs")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = fabs(*M1); }} 1068 1280 if (!strcmp (op, "int")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = (opihi_flt)(long long)(*M1); }} 1281 1282 if (!strcmp (op, "floor")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = floor (*M1); }} 1283 if (!strcmp (op, "ceil")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = ceil (*M1); }} 1284 // if (!strcmp (op, "rint")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = nearbyint (*M1); }} 1285 1069 1286 if (!strcmp (op, "exp")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = exp(*M1); }} 1070 1287 if (!strcmp (op, "ten")) { for (i = 0; i < Nx*Ny; i++, out++, M1++) { *out = pow(10.0,*M1); }} … … 1116 1333 } 1117 1334 1118 if (V1[0].type == 'm') {1335 if (V1[0].type == ST_MATRIX_TMP) { 1119 1336 free (V1[0].buffer[0].header.buffer); 1120 1337 free (V1[0].buffer[0].matrix.buffer); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/pantasks/CheckController.c
r23530 r36680 29 29 if (p != NULL) goto escape; 30 30 31 /** skip past any leading garbage? ***/ 32 33 /** find "Njobs: **/ 34 p = memstr (buffer.buffer, "BEGIN BLOCK Njobs:", MIN(buffer.Nbuffer, 256)); 35 p += strlen("BEGIN BLOCK Njobs:"); 36 31 37 /** parse job list **/ 32 status = sscanf ( buffer.buffer, "%*s%d", &Njobs);38 status = sscanf (p, "%d", &Njobs); 33 39 if (status != 1) goto escape; 34 40 if (VerboseMode()) gprint (GP_ERR, "parse %d jobs on stack %f\n", Njobs, TimerElapsed(&start, TRUE)); 35 41 36 p = buffer.buffer; 42 /* output looks like: 43 BEGIN BLOCK Njobs: NN\n 44 ID name machine\n 45 ID name machine\n 46 */ 47 48 // p is currently pointing at "BEGIN BLOCK Njobs" 49 37 50 for (i = 0; i < Njobs; i++) { 38 51 q = strchr (p, '\n'); … … 67 80 if (p != NULL) goto escape; 68 81 82 /** skip past any leading garbage? ***/ 83 84 /** find "Njobs: **/ 85 p = memstr (buffer.buffer, "BEGIN BLOCK Njobs:", MIN(buffer.Nbuffer, 256)); 86 p += strlen("BEGIN BLOCK Njobs:"); 87 69 88 /** parse job list **/ 70 status = sscanf ( buffer.buffer, "%*s%d", &Njobs);89 status = sscanf (p, "%d", &Njobs); 71 90 if (status != 1) goto escape; 72 91 if (VerboseMode()) gprint (GP_ERR, "check crash stack %f\n", TimerElapsed(&start, TRUE)); 73 92 74 p = buffer.buffer; 93 /* output looks like: 94 BEGIN BLOCK Njobs: NN\n 95 ID name machine\n 96 ID name machine\n 97 */ 98 99 // p is currently pointing at "BEGIN BLOCK Njobs" 100 75 101 for (i = 0; i < Njobs; i++) { 76 102 q = strchr (p, '\n'); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/pantasks/ControllerOps.c
r34088 r36680 259 259 } 260 260 261 if (job[0]. priority) {261 if (job[0].nicelevel) { 262 262 char tmp[64]; 263 snprintf (tmp, 64, " -nice %d", job[0]. priority);263 snprintf (tmp, 64, " -nice %d", job[0].nicelevel); 264 264 strcat (cmd, tmp); 265 265 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/pantasks/JobOps.c
r32632 r36680 107 107 job[0].mode = JOB_CONTROLLER; 108 108 } 109 job[0]. priority = task[0].priority;109 job[0].nicelevel = task[0].nicelevel; 110 110 111 111 /* we need our own copy of task[0].argv argc is the number of valid args, like the usual command line. we -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/pantasks/LocalJob.c
r32632 r36680 162 162 163 163 /* set nice level for the child process -- maybe I should not exit here... */ 164 if (job[0]. priority) {165 status = setpriority (PRIO_PROCESS, pid, job[0]. priority);164 if (job[0].nicelevel) { 165 status = setpriority (PRIO_PROCESS, pid, job[0].nicelevel); 166 166 if (status == -1) { 167 gprint (GP_ERR, "error setting priority\n");167 gprint (GP_ERR, "error setting nice level\n"); 168 168 perror ("setpriority: "); 169 169 exit (2); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/pantasks/TaskOps.c
r32632 r36680 487 487 488 488 NewTask[0].active = TRUE; 489 NewTask[0]. priority= 0;489 NewTask[0].nicelevel = 0; 490 490 return (NewTask); 491 491 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/pantasks/init.c
r32632 r36680 34 34 {1, "halt", halt, "halt the scheduler (no job harvesting)"}, 35 35 {1, "host", task_host, "define host machine for a task"}, 36 {1, "nice", task_nice, "set nice prioritylevel for a task"},36 {1, "nice", task_nice, "set nice level for a task"}, 37 37 {1, "ipptool2book", ipptool2book, "convert queue with ipptool output to book"}, 38 38 {1, "kill", kill_job, "kill job"}, -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/pantasks/init_server.c
r32632 r36680 35 35 {1, "delete", delete_job, "delete job"}, 36 36 {1, "host", task_host, "define host machine for a task"}, 37 {1, "nice", task_nice, "set nice prioritylevel for a task"},37 {1, "nice", task_nice, "set nice level for a task"}, 38 38 {1, "ipptool2book", ipptool2book, "convert queue with ipptool output to book"}, 39 39 {1, "kill", kill_job, "kill job"}, -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/pantasks/task_nice.c
r32632 r36680 4 4 5 5 char *endptr = NULL; 6 int priority;6 int nicelevel; 7 7 Task *task; 8 8 9 9 if (argc != 2) { 10 gprint (GP_ERR, "USAGE: nice ( priority)\n");10 gprint (GP_ERR, "USAGE: nice (nicelevel)\n"); 11 11 return (FALSE); 12 12 } … … 20 20 } 21 21 22 priority= strtol (argv[1], &endptr, 10);22 nicelevel = strtol (argv[1], &endptr, 10); 23 23 if (*endptr) goto fail; 24 if ( priority< 0) goto fail;25 if ( priority> 20) goto fail;24 if (nicelevel < 0) goto fail; 25 if (nicelevel > 20) goto fail; 26 26 27 task[0]. priority = priority;27 task[0].nicelevel = nicelevel; 28 28 JobTaskUnlock(); 29 29 return (TRUE); 30 30 31 31 fail: 32 gprint (GP_ERR, "ERROR: nice ( priority) -- prioritymust be an integer 0 to 20\n");32 gprint (GP_ERR, "ERROR: nice (nicelevel) -- nicelevel must be an integer 0 to 20\n"); 33 33 return (FALSE); 34 34 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/pclient/job.c
r32632 r36680 3 3 int job (int argc, char **argv) { 4 4 5 int i, N, pid, status, priority;5 int i, N, pid, status, nicelevel; 6 6 char **targv; 7 7 8 priority= 0;8 nicelevel = 0; 9 9 if ((N = get_argument (argc, argv, "-nice"))) { 10 10 remove_argument (N, &argc, argv); 11 priority= atoi (argv[N]);11 nicelevel = atoi (argv[N]); 12 12 remove_argument (N, &argc, argv); 13 13 } … … 62 62 63 63 /* set nice level for the child process */ 64 if ( priority) {65 status = setpriority (PRIO_PROCESS, pid, priority);64 if (nicelevel) { 65 status = setpriority (PRIO_PROCESS, pid, nicelevel); 66 66 if (status == -1) { 67 gprint (GP_ERR, "error setting priority\n");67 gprint (GP_ERR, "error setting nicelevel\n"); 68 68 perror ("setpriority: "); 69 69 exit (2); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/pcontrol/CheckBusyJob.c
r28242 r36680 99 99 100 100 // XXX runaway job if output too large? 101 if (job[0].stdout_buf.size > 0x1000000 ) abort();102 if (job[0].stderr_buf.size > 0x1000000 ) abort();101 if (job[0].stdout_buf.size > 0x10000000) abort(); 102 if (job[0].stderr_buf.size > 0x10000000) abort(); 103 103 104 104 // job has exited : move to DONE stack -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/pcontrol/JobOps.c
r32632 r36680 61 61 } 62 62 63 int GetJobStackIDbyName (char *name) { 64 if (!strcasecmp (name, "ALLJOBS")) return PCONTROL_JOB_ALLJOBS; 65 if (!strcasecmp (name, "PENDING")) return PCONTROL_JOB_PENDING; 66 if (!strcasecmp (name, "BUSY")) return PCONTROL_JOB_BUSY ; 67 if (!strcasecmp (name, "RESP")) return PCONTROL_JOB_RESP ; 68 if (!strcasecmp (name, "DONE")) return PCONTROL_JOB_DONE ; 69 if (!strcasecmp (name, "KILL")) return PCONTROL_JOB_KILL ; 70 if (!strcasecmp (name, "EXIT")) return PCONTROL_JOB_EXIT ; 71 if (!strcasecmp (name, "CRASH")) return PCONTROL_JOB_CRASH ; 72 return (PCONTROL_JOB_NONE); 73 } 74 63 75 Stack *GetJobStack (int StackID) { 64 76 switch (StackID) { … … 195 207 } 196 208 197 IDtype AddJob (char *hostname, JobMode mode, int timeout, int priority, int argc, char **argv, int Nxhosts, char **xhosts) {209 IDtype AddJob (char *hostname, JobMode mode, int timeout, int nicelevel, int argc, char **argv, int Nxhosts, char **xhosts) { 198 210 199 211 int JobID; … … 220 232 221 233 job[0].mode = mode; 222 job[0]. priority = priority;234 job[0].nicelevel = nicelevel; 223 235 224 236 job[0].state = 0; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/pcontrol/StartJob.c
r32632 r36680 25 25 bzero (line, Nline); 26 26 strcpy (line, "job"); 27 if (job[0]. priority) {27 if (job[0].nicelevel) { 28 28 char tmp[64]; 29 snprintf (tmp, 64, " -nice %d", job[0]. priority);29 snprintf (tmp, 64, " -nice %d", job[0].nicelevel); 30 30 strcat (line, tmp); 31 31 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/pcontrol/job.c
r32632 r36680 5 5 char *Host = NULL; 6 6 char **targv = NULL; 7 int i, N, Mode, targc, Timeout, priority;7 int i, N, Mode, targc, Timeout, nicelevel; 8 8 IDtype JobID; 9 9 char **xhosts = NULL; … … 43 43 } 44 44 45 priority= 0;45 nicelevel = 0; 46 46 if ((N = get_argument (argc, argv, "-nice"))) { 47 47 remove_argument (N, &argc, argv); 48 priority= atoi (argv[N]);48 nicelevel = atoi (argv[N]); 49 49 remove_argument (N, &argc, argv); 50 50 } … … 76 76 77 77 // a JobID < 0 mean the job was not accepted 78 JobID = AddJob (Host, Mode, Timeout, priority, targc, targv, Nxhosts, xhosts);78 JobID = AddJob (Host, Mode, Timeout, nicelevel, targc, targv, Nxhosts, xhosts); 79 79 gprint (GP_LOG, "JobID: %d\n", (int) JobID); 80 80 return (TRUE); … … 82 82 usage: 83 83 gprint (GP_ERR, "USAGE: job [options] (arg0) (arg1) ... (argN)\n"); 84 gprint (GP_ERR, " options: -host, +host, -timeout, -xhost (host) \n");84 gprint (GP_ERR, " options: -host, +host, -timeout, -xhost (host) -nice (level)\n"); 85 85 gprint (GP_ERR, " arguments of the form @MAX_THREADS@ will be replaced when the job is launched\n"); 86 86 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/pcontrol/jobstack.c
r12470 r36680 22 22 /* print list */ 23 23 LockStack (stack); 24 gprint (GP_LOG, " Njobs: %d\n", stack[0].Nobject);24 gprint (GP_LOG, "BEGIN BLOCK Njobs: %d\n", stack[0].Nobject); 25 25 for (i = 0; i < stack[0].Nobject; i++) { 26 26 job = stack[0].object[i]; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/opihi/pcontrol/status.c
r32632 r36680 1 1 # include "pcontrol.h" 2 2 3 int PrintJobStack (int Nstack );3 int PrintJobStack (int Nstack, char *command, char *hostname, int state, float age); 4 4 int PrintHostStack (int Nstack); 5 5 6 6 int status (int argc, char **argv) { 7 7 8 PrintJobStack (PCONTROL_JOB_ALLJOBS); 9 PrintHostStack (PCONTROL_HOST_ALLHOSTS); 8 int N; 9 10 if (get_argument (argc, argv, "-h")) goto usage; 11 if (get_argument (argc, argv, "-help")) goto usage; 12 if (get_argument (argc, argv, "--help")) goto usage; 13 14 /* I would like to add the following options: 15 * strsub on argv[0] 16 * strsub on hostname, realhost 17 * list hostname and realhost 18 * filter by state 19 * filter by dtime 20 */ 21 22 // -cmd (cmd) 23 // -host (hostname) 24 // -state (busy, pending, done, kill, exit, crash, resp, hung 25 // -age (seconds?) (minutes?) 26 // -nohost 27 28 char *COMMAND = NULL; 29 if ((N = get_argument (argc, argv, "-cmd"))) { 30 remove_argument (N, &argc, argv); 31 COMMAND = strcreate (argv[N]); 32 remove_argument (N, &argc, argv); 33 } 34 35 char *HOSTNAME = NULL; 36 if ((N = get_argument (argc, argv, "-host"))) { 37 remove_argument (N, &argc, argv); 38 HOSTNAME = strcreate (argv[N]); 39 remove_argument (N, &argc, argv); 40 } 41 42 int STATE = PCONTROL_JOB_ALLJOBS; 43 if ((N = get_argument (argc, argv, "-state"))) { 44 remove_argument (N, &argc, argv); 45 STATE = GetJobStackIDbyName (argv[N]); 46 remove_argument (N, &argc, argv); 47 if (STATE == PCONTROL_JOB_NONE) goto usage; 48 } 49 50 float AGE = 0.0; 51 if ((N = get_argument (argc, argv, "-age"))) { 52 remove_argument (N, &argc, argv); 53 AGE = atof (argv[N]); 54 remove_argument (N, &argc, argv); 55 } 56 57 int SHOWHOST = TRUE; 58 if ((N = get_argument (argc, argv, "-nohost"))) { 59 remove_argument (N, &argc, argv); 60 SHOWHOST = FALSE; 61 } 62 if ((N = get_argument (argc, argv, "+jobs"))) { 63 remove_argument (N, &argc, argv); 64 SHOWHOST = FALSE; 65 } 66 67 int SHOWJOBS = TRUE; 68 if ((N = get_argument (argc, argv, "-nojobs"))) { 69 remove_argument (N, &argc, argv); 70 SHOWJOBS = FALSE; 71 } 72 if ((N = get_argument (argc, argv, "+host"))) { 73 remove_argument (N, &argc, argv); 74 SHOWJOBS = FALSE; 75 } 76 77 if (SHOWJOBS) { 78 PrintJobStack (PCONTROL_JOB_ALLJOBS, COMMAND, HOSTNAME, STATE, AGE); 79 } 80 if (SHOWHOST) { 81 PrintHostStack (PCONTROL_HOST_ALLHOSTS); 82 } 10 83 11 84 return (TRUE); 85 86 usage: 87 gprint (GP_ERR, "USAGE: status [-cmd command] [-host hostname] [-state state] [-age seconds] [+jobs,-nohost] [+host,-nojobs]\n"); 88 return FALSE; 12 89 } 13 90 14 int PrintJobStack (int Nstack ) {91 int PrintJobStack (int Nstack, char *command, char *hostname, int state, float age) { 15 92 16 93 int i, j, Nobject; … … 30 107 job = stack[0].object[i]; 31 108 ASSERT (job != NULL, "programming error"); 32 if (job[0].realhost == NULL) { 33 gprint (GP_LOG, "%3d %9s ", i, job[0].hostname); 34 } else { 35 gprint (GP_LOG, "%3d %9s ", i, job[0].realhost); 36 } 37 gprint (GP_LOG, "%7s ", GetJobStackName (job[0].state)); 109 110 char *thishost = (job[0].realhost == NULL) ? job[0].hostname : job[0].realhost; 38 111 39 112 switch (job[0].state) { … … 45 118 gettimeofday (&now, (void *) NULL); 46 119 dtime = DTIME (now, job[0].start); 47 gprint (GP_LOG, "%8.2f ", dtime);48 120 break; 49 121 … … 55 127 default: 56 128 dtime = DTIME (job[0].stop, job[0].start); 57 gprint (GP_LOG, "%8.2f ", dtime);58 129 break; 59 130 } 60 131 132 // check on the filters 133 if (command) { 134 if (!strstr (job[0].argv[0], command)) continue; 135 } 136 if (hostname) { 137 if (!strstr (thishost, hostname)) continue; 138 } 139 if (age > 0.0) { 140 if (dtime < age) continue; 141 } 142 if (state != PCONTROL_JOB_ALLJOBS) { 143 // allow PCONTROL_JOB_RESP == BUSY 144 int validState = FALSE; 145 validState |= (state == PCONTROL_JOB_RESP) && (job[0].state == PCONTROL_JOB_BUSY); 146 validState |= (state == PCONTROL_JOB_BUSY) && (job[0].state == PCONTROL_JOB_RESP); 147 validState |= (state == job[0].state); 148 if (!validState) continue; 149 } 150 151 gprint (GP_LOG, "%3d %9s ", i, thishost); 152 gprint (GP_LOG, "%7s ", GetJobStackName (job[0].state)); 153 gprint (GP_LOG, "%8.2f ", dtime); 154 61 155 PrintID (GP_LOG, job[0].JobID); 62 gprint (GP_LOG, " %2d ", job[0]. priority);156 gprint (GP_LOG, " %2d ", job[0].nicelevel); 63 157 for (j = 0; j < job[0].argc; j++) { 64 158 gprint (GP_LOG, "%s ", job[0].argv[j]); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/photdbc/src/find_images.c
r30616 r36680 25 25 tcoords.pc1_1 = tcoords.pc2_2 = 1.0; 26 26 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 27 strcpy (tcoords.ctype, " RA---TAN");27 strcpy (tcoords.ctype, "DEC--TAN"); 28 28 29 29 timage = gfits_table_get_Image (&db[0].ftable, &Ntimage, &db[0].swapped); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/photdbc/src/join_stars.c
r29938 r36680 57 57 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 58 58 tcoords.Npolyterms = 0; 59 strcpy (tcoords.ctype, " RA---TAN");59 strcpy (tcoords.ctype, "DEC--TAN"); 60 60 61 61 /* project & sort coordinates in local linear frame */ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/Makefile
r35416 r36680 69 69 $(SRC)/resort_catalog.$(ARCH).o \ 70 70 $(SRC)/BrightCatalog.$(ARCH).o \ 71 $(SRC)/assign_images.$(ARCH).o \ 72 $(SRC)/launch_region_hosts.$(ARCH).o \ 73 $(SRC)/relastro_parallel_images.$(ARCH).o \ 74 $(SRC)/relastro_parallel_regions.$(ARCH).o \ 75 $(SRC)/MeanPosIO.$(ARCH).o \ 76 $(SRC)/share_mean_pos.$(ARCH).o \ 77 $(SRC)/share_images_pos.$(ARCH).o \ 78 $(SRC)/ImagePosIO.$(ARCH).o \ 79 $(SRC)/ImageTable.$(ARCH).o \ 80 $(SRC)/markObjects.$(ARCH).o \ 81 $(SRC)/indexCatalogs.$(ARCH).o \ 82 $(SRC)/syncfile.$(ARCH).o \ 71 83 $(SRC)/relastroVisual.$(ARCH).o 72 84 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/include/relastro.h
r35763 r36680 6 6 # include <pthread.h> 7 7 8 # define MARKTIME(MSG,...) { \ 9 gettimeofday (&stopTimer, (void *) NULL); \ 10 float dtime = DTIME (stopTimer, startTimer); \ 11 fprintf (stderr, MSG, __VA_ARGS__); } 12 13 # define INITTIME \ 14 struct timeval startTimer, stopTimer; \ 15 gettimeofday (&startTimer, (void *) NULL); 16 8 17 // choose off_t or int depending on full-scale relphot analysis resources 9 18 // # define IDX_T off_t … … 20 29 typedef enum {FIT_NONE, FIT_AVERAGE, FIT_PM_ONLY, FIT_PAR_ONLY, FIT_PM_AND_PAR} FitMode; 21 30 22 typedef enum {TARGET_NONE, TARGET_SIMPLE, TARGET_CHIPS, TARGET_MOSAICS, TARGET_HIGH_SPEED, TARGET_MERGE_SOURCE, TARGET_UPDATE_OBJECTS, TARGET_UPDATE_OFFSETS, TARGET_LOAD_OBJECTS, TARGET_HPM} FitTarget; 31 typedef enum {OP_NONE, OP_IMAGES, OP_HIGH_SPEED, OP_MERGE_SOURCE, OP_UPDATE_OBJECTS, OP_UPDATE_OFFSETS, OP_LOAD_OBJECTS, OP_HPM, OP_PARALLEL_REGIONS, OP_PARALLEL_IMAGES} RelastroOp; 32 33 typedef enum {TARGET_NONE, TARGET_SIMPLE, TARGET_CHIPS, TARGET_MOSAICS} FitTarget; 23 34 24 35 typedef enum { … … 30 41 MARK_BIG_OFFSET = 0x0010, 31 42 } MeasurementMask; 43 44 typedef struct { 45 float R; 46 float D; 47 unsigned int objID; 48 unsigned int catID; 49 } MeanPos; 50 51 typedef struct { 52 Coords coords; 53 float dXpixSys; 54 float dYpixSys; 55 unsigned int imageID; 56 int nFitAstrom; 57 int flags; 58 } ImagePos; 32 59 33 60 typedef struct { … … 93 120 unsigned int start; 94 121 unsigned int stop; 122 off_t myImage; 95 123 float Mcal; 96 124 float dMcal; … … 113 141 } StatType; 114 142 115 # define MARKTIME(MSG,...) { \116 float dtime; \117 gettimeofday (&stop, (void *) NULL); \118 dtime = DTIME (stop, start); \119 fprintf (stderr, MSG, __VA_ARGS__); }120 121 143 /* global variables set in parameter file */ 122 144 # define DVO_MAX_PATH 1024 … … 129 151 char SKY_TABLE[DVO_MAX_PATH]; 130 152 int SKY_DEPTH; /** XXX EAM : depth of catalog tables, fix usage */ 153 154 // globals for parallel region operations 155 char *REGION_FILE; 156 char *IMAGE_TABLE; 157 int REGION_HOST_ID; 158 int PARALLEL_REGIONS_MANUAL; 131 159 132 160 int HOST_ID; … … 208 236 FitMode FIT_MODE; 209 237 238 RelastroOp RELASTRO_OP; 210 239 FitTarget FIT_TARGET; 211 240 … … 450 479 int hpm_catalogs_parallel (SkyList *skylist); 451 480 int hpm_objects (SkyRegion *region, Catalog *catalog); 481 482 int strextend (char *input, char *format,...); 483 int launch_region_hosts (RegionHostTable *regionHosts); 484 485 int assign_images (FITS_DB *db, RegionHostTable *regionHosts); 486 int select_images_hostregion (RegionHostTable *regionHosts, Image *image, off_t Nimage); 487 int calculate_image_bounds (Image *image, double *rmin, double *rmax, double *dmin, double *dmax, double Rmid); 488 int calculate_host_image_bounds (RegionHostTable *regionHosts); 489 int find_host_for_coords (RegionHostTable *regionHosts, double Rc, double Dc); 490 491 int relastro_parallel_regions (); 492 int relastro_parallel_images (); 493 494 char *make_filename (char *dirname, char *hostname, int hostID, char *tailname); 495 int check_sync_file (char *filename, int nloop); 496 int clear_sync_file (char *filename); 497 int update_sync_file (char *filename, int nloop); 498 499 int share_mean_pos (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop); 500 int slurp_mean_pos (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop); 501 int set_mean_pos (MeanPos *meanpos, Average *average); 502 MeanPos *merge_mean_pos (MeanPos *target, int *ntarget, MeanPos *source, int Nsource); 503 504 int MeanPosSave(char *filename, MeanPos *meanpos, off_t Nmeanpos); 505 MeanPos *MeanPosLoad(char *filename, off_t *nmeanpos); 506 507 int indexCatalogs (Catalog *catalog, int Ncatalog); 508 int catID_and_objID_to_seq (int catID, int objID, int *catSeq, off_t *objSeq); 509 510 int markObjects (Catalog *catalog, int Ncatalog); 511 512 int ImagePosSave(char *filename, ImagePos *image_pos, off_t Nimage_pos); 513 ImagePos *ImagePosLoad(char *filename, off_t *nimage_pos); 514 515 int share_image_pos (RegionHostTable *regionHosts, int nloop); 516 int slurp_image_pos (RegionHostTable *regionHosts, int nloop); 517 ImagePos *merge_image_pos (ImagePos *target, int *ntarget, ImagePos *source, int Nsource); 518 int set_image_pos (ImagePos *image_pos, Image *image); 519 520 Image *ImageTableLoad(char *filename, off_t *nimage); 521 int ImageTableSave (char *filename, Image *images, off_t Nimages); 522 int select_mosaics_hostregion (RegionHostTable *regionHosts, Image *image, off_t Nimage); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src
- Property svn:mergeinfo deleted
-
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/ConfigInit.c
r35105 r36680 18 18 if (VERBOSE) fprintf (stderr, "loaded config file: %s\n", file); 19 19 20 GetConfig (config, "RELASTRO_SIGMA_LIM", "%lf", 0, &SIGMA_LIM); // exclude measurements on this basis 21 GetConfig (config, "RELASTRO_SRC_MEAS_TOOFEW", "%d", 0, &SRC_MEAS_TOOFEW); 20 // set defaults for all of these if they are not used by parallel / remote clients 21 if (!ScanConfig (config, "RELASTRO_SIGMA_LIM", "%lf", 0, &SIGMA_LIM)) SIGMA_LIM = 0.01; 22 if (!ScanConfig (config, "RELASTRO_SRC_MEAS_TOOFEW", "%d", 0, &SRC_MEAS_TOOFEW)) SRC_MEAS_TOOFEW = 3; 22 23 23 24 if (!ScanConfig (config, "RELASTRO_IMFIT_CLIP_NITER", "%d", 0, &IMFIT_CLIP_NITER)) IMFIT_CLIP_NITER = 3; … … 25 26 if (!ScanConfig (config, "RELASTRO_IMFIT_SYS_SIGMA_LIM", "%lf", 0, &IMFIT_SYS_SIGMA_LIM)) IMFIT_SYS_SIGMA_LIM = 0.01; 26 27 27 GetConfig (config, "PM_DT_MIN", "%lf", 0, &PM_DT_MIN); 28 GetConfig (config, "PM_TOOFEW", "%d", 0, &PM_TOOFEW); 29 GetConfig (config, "POS_TOOFEW", "%d", 0, &POS_TOOFEW); 28 if (!ScanConfig (config, "PM_DT_MIN", "%lf", 0, &PM_DT_MIN)) PM_DT_MIN = 0.25; 29 if (!ScanConfig (config, "PM_TOOFEW", "%d", 0, &PM_TOOFEW)) PM_TOOFEW = 4; 30 if (!ScanConfig (config, "POS_TOOFEW", "%d", 0, &POS_TOOFEW)) POS_TOOFEW = 1; 31 if (!ScanConfig (config, "PAR_FACTOR_MIN", "%lf", 0, &PAR_FACTOR_MIN)) PAR_FACTOR_MIN = 0.2; 32 if (!ScanConfig (config, "RELASTRO_MAP_NX", "%d", 0, &NX_MAP)) NX_MAP = 5; 33 if (!ScanConfig (config, "RELASTRO_MAP_NY", "%d", 0, &NY_MAP)) NY_MAP = 5; 34 if (!ScanConfig (config, "RELASTRO_DPOS_MAX", "%lf", 0, &DPOS_MAX)) DPOS_MAX = 6.0; 35 if (!ScanConfig (config, "ADDSTAR_RADIUS", "%lf", 0, &ADDSTAR_RADIUS)) ADDSTAR_RADIUS = 1.0; 30 36 31 GetConfig (config, "PAR_FACTOR_MIN", "%lf", 0, &PAR_FACTOR_MIN); 32 33 GetConfig (config, "RELASTRO_MAP_NX", "%d", 0, &NX_MAP); 34 GetConfig (config, "RELASTRO_MAP_NY", "%d", 0, &NY_MAP); 35 GetConfig (config, "RELASTRO_DPOS_MAX", "%lf", 0, &DPOS_MAX); 36 GetConfig (config, "ADDSTAR_RADIUS", "%lf", 0, &ADDSTAR_RADIUS); 37 38 if (!ScanConfig (config, "USE_FIXED_PIXCOORDS", "%d", 0, &USE_FIXED_PIXCOORDS)) { 39 USE_FIXED_PIXCOORDS = FALSE; 40 } 37 if (!ScanConfig (config, "USE_FIXED_PIXCOORDS", "%d", 0, &USE_FIXED_PIXCOORDS)) USE_FIXED_PIXCOORDS = FALSE; 41 38 42 39 // force CATDIR to be absolute (so parallel mode will work) … … 56 53 sprintf (ImageCat, "%s/Images.dat", CATDIR); 57 54 58 if (!ScanConfig (config, "SKY_DEPTH", "%d", 0, &SKY_DEPTH)) { 59 SKY_DEPTH = 2; 60 } 61 if (!ScanConfig (config, "SKY_TABLE", "%s", 0, SKY_TABLE)) { 62 SKY_TABLE[0] = 0; 63 } 55 if (!ScanConfig (config, "SKY_DEPTH", "%d", 0, &SKY_DEPTH)) SKY_DEPTH = 2; 56 if (!ScanConfig (config, "SKY_TABLE", "%s", 0, SKY_TABLE)) SKY_TABLE[0] = 0; 64 57 65 58 if (*CATMODE == 0) strcpy (CATMODE, "RAW"); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/ImageOps.c
r35763 r36680 226 226 Measure *measureBig = &catalog[cat].measure[meas]; 227 227 int TESTPT = FALSE; 228 TESTPT |= (measureBig->imageID == CAT_ID_SRC) && (measureBig->detID == OBJ_ID_SRC);229 TESTPT |= (measureBig->imageID == CAT_ID_DST) && (measureBig->detID == OBJ_ID_DST);228 TESTPT |= CAT_ID_SRC && OBJ_ID_SRC && (measureBig->imageID == CAT_ID_SRC) && (measureBig->detID == OBJ_ID_SRC); 229 TESTPT |= CAT_ID_DST && OBJ_ID_DST && (measureBig->imageID == CAT_ID_DST) && (measureBig->detID == OBJ_ID_DST); 230 230 if (TESTPT) { 231 231 fprintf (stderr, "got test det\n"); … … 462 462 int TESTPT = FALSE; 463 463 464 TESTPT |= (measure->imageID == CAT_ID_SRC) && (measure->detID == OBJ_ID_SRC);465 TESTPT |= (measure->imageID == CAT_ID_DST) && (measure->detID == OBJ_ID_DST);464 TESTPT |= CAT_ID_SRC && OBJ_ID_SRC && (measure->imageID == CAT_ID_SRC) && (measure->detID == OBJ_ID_SRC); 465 TESTPT |= CAT_ID_DST && OBJ_ID_DST && (measure->imageID == CAT_ID_DST) && (measure->detID == OBJ_ID_DST); 466 466 if (TESTPT) { 467 467 fprintf (stderr, "got test det\n"); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/MosaicOps.c
r27581 r36680 11 11 12 12 // list of mosaic associated with each image 13 static off_t Nmosaic_for_images; // number of images (for off_ternal checks)13 static off_t Nmosaic_for_images; // number of images (for internal checks) 14 14 static off_t *mosaic_for_images; // array of: image -> mosaic 15 15 … … 105 105 mosaic[Nmosaic].secz = image[i].secz; 106 106 mosaic[Nmosaic].coords = image[i].coords; 107 mosaic[Nmosaic].myImage = i; 107 108 108 109 // init the mosaic_own_images array data … … 135 136 ALLOCATE (mosaic_for_images, off_t, Nmosaic_for_images); 136 137 138 // emit an error if we miss mosaics, but stop if we miss too many 139 int NmissMosaic = 0; 140 int NtestMosaic = 0; 141 137 142 /* now assign the WRP images to these mosaics */ 138 143 for (i = 0; i < Nimage; i++) { … … 140 145 141 146 if (strcmp(&image[i].coords.ctype[4], "-WRP")) continue; 147 NtestMosaic ++; 142 148 143 149 /* set image time range */ … … 147 153 Nmos = getMosaicByTimes (start, stop, startMos, stopMos, indexMos); 148 154 if (Nmos == -1) { 149 fprintf (stderr, "cannot match mosaic for %s\n", image[i].name); 155 if (NmissMosaic < 1000) { 156 fprintf (stderr, "cannot match mosaic for %s\n", image[i].name); 157 } 158 NmissMosaic ++; 150 159 continue; 151 160 } … … 164 173 } 165 174 175 fprintf (stderr, "mosaic matching : %d of possible %d failed to match\n", NmissMosaic, NtestMosaic); 176 if (NmissMosaic > 0.5*NtestMosaic) { 177 fprintf (stderr, "serious problem with mosaic matching\n"); 178 exit (5); 179 } 180 166 181 free (startMos); 167 182 free (stopMos); … … 250 265 if (im >= Nmosaic_for_images) abort(); 251 266 252 // search for the mosaic that 267 // search for the mosaic that matches this image 253 268 mos = mosaic_for_images[im]; 254 269 if (mos < 0) return NULL; … … 256 271 return &mosaic[mos]; 257 272 } 273 274 // extend each host image table to include the mosaic 'images' needed by the host 275 int select_mosaics_hostregion (RegionHostTable *regionHosts, Image *image, off_t Nimage) { 276 277 int i; 278 off_t j; 279 char *mosaicUsed; 280 281 ALLOCATE (mosaicUsed, char, Nmosaic); 282 283 // we need to add the mosaics to each of the region hosts lists of images 284 for (i = 0; i < regionHosts->Nhosts; i++) { 285 286 int Nadd = 0; 287 int NADD = 100; 288 off_t *addMosaic = NULL; 289 ALLOCATE (addMosaic, off_t, NADD); 290 291 // reset the mosaicUsed flags (valid only for this host) 292 memset (mosaicUsed, 0, Nmosaic * sizeof(char)); 293 294 RegionHostInfo *host = ®ionHosts->hosts[i]; 295 296 // find the mosaics associated with a given 297 for (j = 0; j < host->Nimage; j++) { 298 299 int im = host->imseq[j]; 300 301 if (im < 0) abort(); 302 if (im >= Nmosaic_for_images) abort(); 303 304 // search for the mosaic that matches this image (skip unmatched images) 305 off_t mos = mosaic_for_images[im]; 306 if (mos < 0) continue; 307 308 if (mosaicUsed[mos]) continue; 309 310 mosaicUsed[mos] = TRUE; 311 addMosaic[Nadd] = mos; 312 Nadd ++; 313 314 CHECK_REALLOCATE (addMosaic, off_t, NADD, Nadd, 100); 315 } 316 317 REALLOCATE (host->image, Image, host->Nimage + Nadd); 318 319 for (j = 0; j < Nadd; j++) { 320 off_t mos = addMosaic[j]; 321 off_t mos_im = mosaic[mos].myImage; 322 323 host->image[host->Nimage + j] = image[mos_im]; 324 } 325 326 host->Nimage += Nadd; 327 } 328 return TRUE; 329 } 330 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/StarMaps.c
r35105 r36680 59 59 off_t i, N, Nimages; 60 60 int xbin, ybin; 61 struct timeval start, stop;62 61 63 gettimeofday (&start, (void *) NULL);62 INITTIME; 64 63 65 64 // Images *images = getimages(&Nimages, NULL); return value ignored -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/UpdateObjects.c
r35763 r36680 1 1 # include "relastro.h" 2 2 3 static off_t Nmax;3 static off_t Nmax; 4 4 static double *X, *dX; 5 5 static double *Y, *dY; … … 36 36 ALLOCATE (pX, double, MAX (1, Nmax)); 37 37 ALLOCATE (pY, double, MAX (1, Nmax)); 38 } 39 40 void freeObjectData () { 41 42 free (R); 43 free (D); 44 free (T); 45 free (X); 46 free (Y); 47 48 free (dR); 49 free (dD); 50 free (dT); 51 free (dX); 52 free (dY); 53 54 free (pX); 55 free (pY); 38 56 } 39 57 … … 67 85 coords.pc1_2 = coords.pc2_1 = 0.0; 68 86 coords.Npolyterms = 1; 69 strcpy (coords.ctype, " RA---SIN");87 strcpy (coords.ctype, "DEC--SIN"); 70 88 71 89 XVERB = FALSE; … … 205 223 if (((mode == FIT_PM_ONLY) || (mode == FIT_PM_AND_PAR)) && (N <= PM_TOOFEW)) mode = FIT_AVERAGE; 206 224 207 if ( FIT_TARGET == TARGET_HIGH_SPEED) {225 if (RELASTRO_OP == OP_HIGH_SPEED) { 208 226 Tmean = 0.5*(Tmax - Tmin); 209 227 } else { … … 412 430 } 413 431 432 freeObjectData (); 433 414 434 if (VERBOSE) fprintf (stderr, "fitted "OFF_T_FMT" objects ("OFF_T_FMT" ave, "OFF_T_FMT" pm, "OFF_T_FMT" par), skipped "OFF_T_FMT", "OFF_T_FMT" have too large an offset\n", (NaveSum + NpmSum + NparSum), NaveSum, NpmSum, NparSum, NskipSum, NoffSum); 415 435 return (TRUE); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/args.c
r35763 r36680 13 13 /* possible operations */ 14 14 FIT_TARGET = TARGET_NONE; 15 RELASTRO_OP = OP_NONE; 15 16 FIT_MODE = FIT_AVERAGE; 16 17 … … 21 22 if (N > argc - 6) usage_merge_source(); 22 23 if (strcmp(argv[N+3], "into")) usage_merge_source(); 23 FIT_TARGET = TARGET_MERGE_SOURCE;24 RELASTRO_OP = OP_MERGE_SOURCE; 24 25 remove_argument (N, &argc, argv); 25 26 OBJ_ID_SRC = strtol(argv[N], &endptr, 0); … … 43 44 if ((N = get_argument (argc, argv, "-update-objects"))) { 44 45 remove_argument (N, &argc, argv); 45 FIT_TARGET = TARGET_UPDATE_OBJECTS;46 RELASTRO_OP = OP_UPDATE_OBJECTS; 46 47 } 47 48 48 49 if ((N = get_argument (argc, argv, "-update-offsets"))) { 49 50 remove_argument (N, &argc, argv); 50 FIT_TARGET = TARGET_UPDATE_OFFSETS; 51 RELASTRO_OP = OP_UPDATE_OFFSETS; 52 } 53 54 // elements needed for parallel regions / parallel images 55 REGION_FILE = NULL; 56 if ((N = get_argument (argc, argv, "-region-hosts"))) { 57 remove_argument (N, &argc, argv); 58 REGION_FILE = strcreate (argv[N]); 59 remove_argument (N, &argc, argv); 60 } 61 62 REGION_HOST_ID = 0; 63 if ((N = get_argument (argc, argv, "-region-hostID"))) { 64 remove_argument (N, &argc, argv); 65 REGION_HOST_ID = atoi (argv[N]); 66 remove_argument (N, &argc, argv); 67 } 68 69 IMAGE_TABLE = NULL; 70 if ((N = get_argument (argc, argv, "-parallel-images"))) { 71 remove_argument (N, &argc, argv); 72 RELASTRO_OP = OP_PARALLEL_IMAGES; 73 if (N >= argc) usage(); 74 IMAGE_TABLE = strcreate (argv[N]); 75 remove_argument (N, &argc, argv); 76 if (!REGION_FILE) usage(); 77 } 78 79 if ((N = get_argument (argc, argv, "-images"))) { 80 remove_argument (N, &argc, argv); 81 RELASTRO_OP = OP_IMAGES; 82 } 83 84 PARALLEL_REGIONS_MANUAL = FALSE; 85 if ((N = get_argument (argc, argv, "-parallel-regions"))) { 86 remove_argument (N, &argc, argv); 87 RELASTRO_OP = OP_PARALLEL_REGIONS; 88 if (!REGION_FILE) usage(); 89 if ((N = get_argument (argc, argv, "-parallel-regions-manual"))) { 90 remove_argument (N, &argc, argv); 91 PARALLEL_REGIONS_MANUAL = TRUE; 92 } 51 93 } 52 94 … … 90 132 // XXX include a parallax / no-parallax option 91 133 if (N >= argc - 4) usage(); 92 FIT_TARGET = TARGET_HIGH_SPEED;134 RELASTRO_OP = OP_HIGH_SPEED; 93 135 remove_argument (N, &argc, argv); 94 136 PHOTCODE_A_LIST = strcreate(argv[N]); … … 104 146 if ((N = get_argument (argc, argv, "-hpm"))) { 105 147 if (N >= argc - 2) usage(); 106 FIT_TARGET = TARGET_HPM;148 RELASTRO_OP = OP_HPM; 107 149 remove_argument (N, &argc, argv); 108 150 RADIUS = atof(argv[N]); … … 116 158 remove_argument (N, &argc, argv); 117 159 PARALLEL_OUTPUT = TRUE; 118 if (( FIT_TARGET != TARGET_HIGH_SPEED) && (FIT_TARGET != TARGET_HPM)) {160 if ((RELASTRO_OP != OP_HIGH_SPEED) && (RELASTRO_OP != OP_HPM)) { 119 161 fprintf (stderr, "-parallel-output only valid for -high-speed or -hpm modes\n"); 120 162 exit (1); … … 143 185 } 144 186 145 if (FIT_TARGET == TARGET_NONE) usage(); 187 if (RELASTRO_OP == OP_NONE) usage(); 188 189 if (((RELASTRO_OP == OP_IMAGES) || (RELASTRO_OP == OP_PARALLEL_REGIONS) || (RELASTRO_OP == OP_PARALLEL_IMAGES)) && (FIT_TARGET == TARGET_NONE)) usage(); 146 190 147 191 /* specify portion of the sky : allow default of all sky? */ … … 427 471 428 472 /* possible operations */ 429 FIT_TARGET= TARGET_NONE;473 RELASTRO_OP = TARGET_NONE; 430 474 FIT_MODE = FIT_AVERAGE; 431 475 … … 437 481 BCATALOG = NULL; 438 482 483 REGION_FILE = NULL; 484 REGION_HOST_ID = 0; 485 IMAGE_TABLE = NULL; 486 PARALLEL_REGIONS_MANUAL = FALSE; 487 439 488 HOST_ID = 0; 440 489 if ((N = get_argument (argc, argv, "-hostID"))) { … … 457 506 BCATALOG = strcreate(argv[N]); 458 507 remove_argument (N, &argc, argv); 459 FIT_TARGET = TARGET_LOAD_OBJECTS;508 RELASTRO_OP = OP_LOAD_OBJECTS; 460 509 } 461 510 462 511 if ((N = get_argument (argc, argv, "-update-objects"))) { 463 512 remove_argument (N, &argc, argv); 464 FIT_TARGET = TARGET_UPDATE_OBJECTS;513 RELASTRO_OP = OP_UPDATE_OBJECTS; 465 514 } 466 515 467 516 if ((N = get_argument (argc, argv, "-update-offsets"))) { 468 517 remove_argument (N, &argc, argv); 469 FIT_TARGET = TARGET_UPDATE_OFFSETS;518 RELASTRO_OP = OP_UPDATE_OFFSETS; 470 519 } 471 520 … … 487 536 // XXX include a parallax / no-parallax option 488 537 if (N >= argc - 5) usage_client(); 489 FIT_TARGET = TARGET_HIGH_SPEED;538 RELASTRO_OP = OP_HIGH_SPEED; 490 539 remove_argument (N, &argc, argv); 491 540 PHOTCODE_A_LIST = strcreate(argv[N]); … … 501 550 if ((N = get_argument (argc, argv, "-hpm"))) { 502 551 if (N >= argc - 3) usage(); 503 FIT_TARGET = TARGET_HPM;552 RELASTRO_OP = OP_HPM; 504 553 remove_argument (N, &argc, argv); 505 554 RADIUS = atof(argv[N]); … … 539 588 } 540 589 541 if ( FIT_TARGET == TARGET_NONE) usage_client();590 if (RELASTRO_OP == OP_NONE) usage_client(); 542 591 543 592 /* specify portion of the sky : allow default of all sky? */ … … 718 767 719 768 void usage () { 720 fprintf (stderr, "ERROR: USAGE: relastro -update-simple [options]\n"); 721 fprintf (stderr, " OR: relastro -update-chips [options]\n"); 722 fprintf (stderr, " OR: relastro -update-mosaic [options]\n"); 769 fprintf (stderr, "ERROR: USAGE: relastro -images -update-simple [options]\n"); 770 fprintf (stderr, " OR: relastro -images -update-chips [options]\n"); 771 fprintf (stderr, " OR: relastro -images -update-mosaic [options]\n"); 772 fprintf (stderr, " OR: relastro -parallel-regions -update-simple [options]\n"); 773 fprintf (stderr, " OR: relastro -parallel-regions -update-chips [options]\n"); 774 fprintf (stderr, " OR: relastro -parallel-regions -update-mosaic [options]\n"); 775 fprintf (stderr, " OR: relastro -parallel-images -update-simple [options]\n"); 776 fprintf (stderr, " OR: relastro -parallel-images -update-chips [options]\n"); 777 fprintf (stderr, " OR: relastro -parallel-images -update-mosaic [options]\n"); 723 778 fprintf (stderr, " OR: relastro -update-objects [options]\n"); 724 779 fprintf (stderr, " OR: relastro -high-speed [options]\n"); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/high_speed_objects.c
r35494 r36680 161 161 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 162 162 tcoords.Npolyterms = 1; 163 strcpy (tcoords.ctype, " RA---ARC");163 strcpy (tcoords.ctype, "DEC--ARC"); 164 164 165 165 /* build spatial index (RA sort) referencing input array sequence */ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/hpm_objects.c
r35494 r36680 138 138 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 139 139 tcoords.Npolyterms = 1; 140 strcpy (tcoords.ctype, " RA---ARC");140 strcpy (tcoords.ctype, "DEC--ARC"); 141 141 142 142 /* build spatial index (RA sort) referencing input array sequence */ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/initialize.c
r34429 r36680 6 6 args (argc, argv); 7 7 8 if ( FIT_TARGET == TARGET_MERGE_SOURCE) return;8 if (RELASTRO_OP == OP_MERGE_SOURCE) return; 9 9 10 10 fprintf (stderr, "PHOTCODE_KEEP_LIST: %s\n", PHOTCODE_KEEP_LIST); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/load_catalogs.c
r35105 r36680 115 115 Catalog *load_catalogs_parallel (SkyList *sky, int *Ncatalog) { 116 116 117 char uniquer[12]; 118 int TIME = time(NULL); 119 int PID = getpid(); 120 snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000); 121 117 122 // load the list of hosts 118 123 HostTable *table = HostTableLoad (CATDIR, sky->hosts); … … 131 136 132 137 ALLOCATE (table->hosts[i].results, char, 1024); 133 snprintf (table->hosts[i].results, 1024, "%s/relastro.catalog. subset.dat", table->hosts[i].pathname);138 snprintf (table->hosts[i].results, 1024, "%s/relastro.catalog.%s.dat", table->hosts[i].pathname, uniquer); 134 139 135 140 // options / arguments that can affect relastro_client -load: -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/load_images.c
r35763 r36680 1 1 # include "relastro.h" 2 3 # define MARKTIME(MSG,...) { \4 float dtime; \5 gettimeofday (&stop, (void *) NULL); \6 dtime = DTIME (stop, start); \7 fprintf (stderr, MSG, __VA_ARGS__); }8 2 9 3 int load_images (FITS_DB *db, SkyList *skylist, int UseFullOverlap) { … … 12 6 off_t Nimage, Nsubset; 13 7 off_t *LineNumber; 14 struct timeval start, stop;15 8 16 gettimeofday (&start, (void *) NULL);9 INITTIME; 17 10 18 11 // convert database table to internal structure … … 35 28 36 29 /* unlock, if we can (else, unlocked below) */ 37 int unlockImages = !UPDATE || ( FIT_TARGET == TARGET_UPDATE_OFFSETS);30 int unlockImages = !UPDATE || (RELASTRO_OP == OP_UPDATE_OFFSETS); 38 31 if (unlockImages) dvo_image_unlock (db); 39 32 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/relastro.c
r35763 r36680 10 10 SkyList *skylist = SkyListByPatch (sky, -1, &UserPatch); 11 11 12 switch ( FIT_TARGET) {13 case TARGET_UPDATE_OBJECTS:12 switch (RELASTRO_OP) { 13 case OP_UPDATE_OBJECTS: 14 14 /* the object analysis is a separate process iterating over catalogs */ 15 15 relastro_objects (skylist, 0, NULL); 16 16 exit (0); 17 17 18 case TARGET_HIGH_SPEED:18 case OP_HIGH_SPEED: 19 19 /* high-speed is a 2pt cross-correlation process for linking moving objects (high PM) */ 20 20 high_speed_catalogs (sky, skylist, 0, NULL); 21 21 exit (0); 22 22 23 case TARGET_HPM:23 case OP_HPM: 24 24 hpm_catalogs (sky, skylist, 0, NULL); 25 25 exit (0); 26 26 27 case TARGET_MERGE_SOURCE:27 case OP_MERGE_SOURCE: 28 28 /* a special method to manually merge unlinked detections of sources togther (not parallel) */ 29 29 relastro_merge_source (sky); 30 30 exit (0); 31 31 32 case TARGET_SIMPLE: 33 case TARGET_CHIPS: 34 case TARGET_MOSAICS: 32 case OP_IMAGES: 35 33 relastro_images (skylist); 36 34 exit (0); 37 35 38 case TARGET_UPDATE_OFFSETS:36 case OP_UPDATE_OFFSETS: 39 37 // iterate over catalogs to make detection coordinates consistant 40 38 UpdateObjectOffsets (skylist, 0, NULL); 39 exit (0); 40 41 case OP_PARALLEL_REGIONS: 42 // run image updates in parallel across multiple remote machines 43 relastro_parallel_regions (); 44 exit (0); 45 46 case OP_PARALLEL_IMAGES: 47 // operation on the remote machines in the PARALLEL_REGION mode 48 relastro_parallel_images (); 41 49 exit (0); 42 50 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/relastro_client.c
r35763 r36680 28 28 SkyList *skylist = SkyListByPatch (sky, -1, &UserPatch); 29 29 30 switch ( FIT_TARGET) {30 switch (RELASTRO_OP) { 31 31 32 case TARGET_LOAD_OBJECTS: {32 case OP_LOAD_OBJECTS: { 33 33 // USAGE: relastro_client -load-objects 34 34 int Ncatalog; 35 35 Catalog *catalog = load_catalogs (skylist, &Ncatalog, TRUE, HOST_ID, HOSTDIR); 36 36 if (!catalog) { 37 fprintf (stderr, "ERROR loading catalogs from %s\n", CATDIR);38 exit (2);37 fprintf (stderr, "ERROR loading catalogs from %s\n", CATDIR); 38 exit (2); 39 39 } 40 40 BrightCatalog *bcatalog = BrightCatalogMerge (catalog, Ncatalog); 41 41 if (!BrightCatalogSave (BCATALOG, bcatalog)) { 42 fprintf (stderr, "ERROR saving bright catalog from %s\n", CATDIR);43 exit (2);42 fprintf (stderr, "ERROR saving bright catalog from %s\n", CATDIR); 43 exit (2); 44 44 } 45 45 break; 46 46 } 47 47 48 case TARGET_UPDATE_OBJECTS: {48 case OP_UPDATE_OBJECTS: { 49 49 // USAGE: relastro_client -update-objects 50 50 relastro_objects (skylist, HOST_ID, HOSTDIR); … … 52 52 } 53 53 54 case TARGET_HIGH_SPEED: {54 case OP_HIGH_SPEED: { 55 55 // USAGE: relastro_client -high-speed 56 56 high_speed_catalogs (sky, skylist, HOST_ID, HOSTDIR); … … 58 58 } 59 59 60 case TARGET_HPM: {60 case OP_HPM: { 61 61 // USAGE: relastro_client -high-speed 62 62 hpm_catalogs (sky, skylist, HOST_ID, HOSTDIR); … … 64 64 } 65 65 66 // XXX loading the images is fairly costly -- see if we can do an image subset 67 case TARGET_UPDATE_OFFSETS: {66 // XXX loading the images is fairly costly -- see if we can do an image subset? 67 case OP_UPDATE_OFFSETS: { 68 68 FITS_DB db; 69 69 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/relastro_images.c
r35763 r36680 6 6 Catalog *catalog; 7 7 FITS_DB db; 8 struct timeval start, stop;9 8 10 gettimeofday (&start, (void *) NULL);9 INITTIME; 11 10 12 11 /* register database handle with shutdown procedure */ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/relastro_objects.c
r35763 r36680 144 144 // PM_TOOFEW 145 145 // SRC_MEAS_TOOFEW 146 // FIT_TARGET147 146 148 147 char command[1024]; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/resort_catalog.c
r34088 r36680 30 30 if (catalog[0].sorted == TRUE) return; 31 31 32 // struct timeval start, stop; 33 // gettimeofday (&start, NULL); 32 // INITTIME; 34 33 35 34 /* internal counters */ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/select_images.c
r35763 r36680 15 15 void dsortindex (double *X, off_t *Y, int N); 16 16 off_t getRegionStartByRA (double R, double *Rref, off_t Nregions); 17 18 # define MARKTIME(MSG,...) { \19 float dtime; \20 gettimeofday (&stop, (void *) NULL); \21 dtime = DTIME (stop, start); \22 fprintf (stderr, MSG, __VA_ARGS__); }23 17 24 18 Image *select_images (SkyList *skylist, Image *timage, off_t Ntimage, off_t **LineNumber, off_t *Nimage, int UseFullOverlap) { … … 31 25 Coords tcoords; 32 26 SkyRegionCoords *skycoords; 33 struct timeval start, stop;34 27 35 28 double RmaxSkyRegion, RminSkyRegion, RmidSkyRegion, DminSkyRegion, DmaxSkyRegion; … … 50 43 } 51 44 52 gettimeofday (&start, (void *) NULL);45 INITTIME; 53 46 54 47 // the comparison is made in the catalog local projection. below we set crval1,2 … … 57 50 tcoords.pc1_1 = tcoords.pc2_2 = 1.0; 58 51 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 59 strcpy (tcoords.ctype, " RA---TAN");52 strcpy (tcoords.ctype, "DEC--TAN"); 60 53 61 54 ALLOCATE (skycoords, SkyRegionCoords, skylist[0].Nregions); … … 132 125 if (NphotcodesKeep > 0) { 133 126 found = FALSE; 134 // XXX this bit of code excludes DIS mosaics and should be fixed 127 // we have to keep DIS mosaics explicitly (photcode = 0) 128 if (!strcmp(&timage[i].coords.ctype[4], "-DIS")) found = TRUE; 135 129 for (k = 0; (k < NphotcodesKeep) && !found; k++) { 136 130 if (photcodesKeep[k][0].code == timage[i].photcode) found = TRUE; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relastro/src/testparallax.c
r34088 r36680 57 57 coords.pc1_2 = coords.pc2_1 = 0.0; 58 58 coords.Npolyterms = 1; 59 strcpy (coords.ctype, " RA---SIN");59 strcpy (coords.ctype, "DEC--SIN"); 60 60 61 61 // use one point as a local reference -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/Makefile
r35416 r36680 47 47 $(SRC)/relphot_images.$(ARCH).o \ 48 48 $(SRC)/relphot_objects.$(ARCH).o \ 49 $(SRC)/relphot_parallel_regions.$(ARCH).o \ 50 $(SRC)/relphot_parallel_images.$(ARCH).o \ 49 51 $(SRC)/select_images.$(ARCH).o \ 52 $(SRC)/assign_images.$(ARCH).o \ 53 $(SRC)/launch_region_hosts.$(ARCH).o \ 54 $(SRC)/ImageTable.$(ARCH).o \ 55 $(SRC)/ImageMagIO.$(ARCH).o \ 56 $(SRC)/syncfile.$(ARCH).o \ 57 $(SRC)/share_image_mags.$(ARCH).o \ 58 $(SRC)/share_mean_mags.$(ARCH).o \ 59 $(SRC)/MeanMagIO.$(ARCH).o \ 60 $(SRC)/indexCatalog.$(ARCH).o \ 50 61 $(SRC)/client_logger.$(ARCH).o \ 51 62 $(SRC)/setExclusions.$(ARCH).o \ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/doc/parallel.txt
r33651 r36680 1 2 2014.02.15 3 4 Nearly done with the relphot mods. some outstanding questions; 5 6 * image vs mosaic? 7 * how do decide which images need to be shared? 8 9 2014.02.14 10 11 more relphot notes: 12 13 * I load the catalogs, with a 14 15 2014.02.12 16 17 I am making progess on the relphot -parallel-regions implementation. some things I need to deal with: 18 19 * assign_images: select mosaics for all images saved for a given host (need to supply them as well) 20 ** I need to decide on the Image / Mosaic split. If I am calibrating by image, then the image center defines ownership 21 ** if I am calibrating by exposure, then the mosaic center must define ownership 22 o determine SkyList covering the images for region host 23 o tag detections and objects which I own or do not own 24 o ImageOps.c / matchImage matches detections to images and needs to handle mine / not mine cases 25 o ditto for matchMosaics 26 o load_catalogs : I need to make my requested catalogs unique (just add uniquer to load_catalogs.c:130 27 o figure out what fields I'm saving in meanmags and how to construct it 28 -- mag, objID, catID, photcode, (dmag or other stats?) 29 * from which hosts do I slurp mean mags? 30 o function to merge a new meanmag array into the existing one 31 o how to go from (objID,catID) to a given catalog[i].average[j] 32 33 2014.02.06 34 35 ** a single region-level host owns images for which the center lands 36 in its region. 37 38 ** it owns detections which come from images which it owns 39 40 ** it owns objects which land in its region 41 42 Extending parallel relphot processing to split the sky (and images) 43 into regions, each of which runs in parallel at the same time: 44 45 Top Level (relphot -parallel-images): 46 * define regions of the sky -> hosts 47 * load images, assign to hosts 48 * launch region-level jobs on remote hosts 49 50 Region Level (relphot -parallel-images-region) 51 * load my image subset table 52 * request objects and detections for my skyregion 53 * match images & objects, etc 54 55 * update my image parameters 56 * update my detections 57 * write out detections 58 * load detections from my border hosts 59 * match to my objects 60 * update my objects 61 * write out objects 62 * load objects from my border hosts 63 * update images 64 (iterate N times) 65 * write out image parameters 66 67 Top Level 68 * read image parameters, update 69 * update objects 1 70 2 71 2012.02.13 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/include/relphot.h
r35806 r36680 23 23 // # define IDX_T off_t 24 24 # define IDX_T int 25 26 typedef enum { 27 MODE_ERROR = 0, 28 UPDATE_IMAGES, 29 UPDATE_AVERAGES, 30 PARALLEL_REGIONS, 31 PARALLEL_IMAGES, 32 APPLY_OFFSETS, 33 } RelphotMode; 25 34 26 35 typedef enum { … … 86 95 // others are only used on the final output steps. 87 96 88 double *list; // list of measure.mag values for a given star 89 double *dlist; // mag errors for a star 90 double *wlist; // weights to use for mean mags 91 double *aplist; // ap mags for a star 92 double *kronlist; // kron mags for a star 97 double *Mpsflist; // list of measure.mag values for a given star 98 double *dpsflist; // mag errors for a star 99 double *wpsflist; // weights to use for mean mags 100 101 double *Maplist; // ap mags for a star 102 double *daplist; // ap mags for a star 103 double *waplist; // ap mags for a star 104 105 double *Mkronlist; // kron mags for a star 93 106 double *dkronlist; // kron mag errors 107 double *wkronlist; // kron mag errors 94 108 95 109 double *psfqf_list; // psfqf for all filters … … 97 111 double *stargal_list; // stargal for all filters 98 112 99 StatType stats;113 StatType psfstats; 100 114 StatType apstats; 101 115 StatType kronstats; 102 116 } SetMrelInfo; 117 118 typedef struct { 119 float M; 120 float dM; 121 float Xm; 122 int Nsec; 123 unsigned int objID; 124 unsigned int catID; 125 int photcode; 126 } MeanMag; 127 128 typedef struct { 129 float Mcal; 130 float dMcal; 131 float dMagSys; 132 float Xm; 133 int nFitPhotom; 134 int flags; 135 unsigned int imageID; 136 short ubercalDist; 137 } ImageMag; 103 138 104 139 typedef struct { … … 116 151 unsigned int photom_map_id; 117 152 unsigned int flags; 153 int tessID; 118 154 int projID; 119 155 int skycellID; … … 149 185 int SKY_DEPTH; /** XXX EAM : depth of catalog tables, fix usage */ 150 186 187 // globals for parallel region operations 188 char *REGION_FILE; 189 char *IMAGE_TABLE; 190 int REGION_HOST_ID; 191 151 192 int HOST_ID; 152 193 char *HOSTDIR; … … 173 214 int PARALLEL_MANUAL; 174 215 int PARALLEL_SERIAL; 216 217 int PARALLEL_REGIONS_MANUAL; 175 218 176 219 int NTHREADS; … … 260 303 void InterpolateGrid PROTO((float *buffer, int Nx, int Ny, Coords *ccd, Coords *gcoords)); 261 304 off_t *SelectRefMosaic PROTO((Mosaic **refmosaic, off_t *Nimage)); 262 intargs PROTO((int argc, char **argv));305 RelphotMode args PROTO((int argc, char **argv)); 263 306 int args_client PROTO((int argc, char **argv)); 264 307 int bcatalog PROTO((Catalog *subcatalog, Catalog *catalog, int Ncat)); … … 273 316 void findImages PROTO((Catalog *catalog, int Ncatalog, int doImageList)); 274 317 int findMosaics PROTO((Catalog *catalog, int Ncatalog, int doMosaicList)); 318 319 void makeMosaics (Image *image, off_t Nimage); 320 Mosaic *getMosaicForImage (off_t im); 321 void setMosaicCenters (Image *image, off_t Nimage); 275 322 276 323 void set_db (FITS_DB *in); … … 309 356 void initMosaics PROTO((Image *subset, off_t Nsubset, Image *image, char *inSubset, off_t Nimage)); 310 357 void initMrel PROTO((Catalog *catalog, int Ncatalog)); 311 voidinitialize PROTO((int argc, char **argv));358 RelphotMode initialize PROTO((int argc, char **argv)); 312 359 void initialize_client PROTO((int argc, char **argv)); 313 360 void liststats_setmode PROTO((StatType *stats, char *strmode)); … … 397 444 ImageSubset *ImageSubsetLoad(char *filename, off_t *nimage); 398 445 399 int client_logger_init ( );446 int client_logger_init (char *dirname); 400 447 int client_logger_message (char *format,...); 401 448 402 449 int MatchImageName (off_t meas, int cat, char *name); 403 int MatchImageSkycellID (off_t meas, int cat, int myProjectionID, int mySkycellID); 404 405 int load_tree (char *treefile); 406 int BoundaryTreePrimaryCell (char *primaryCellName, double ra, double dec); 407 int BoundaryTreePrimaryCellIDs (int *projID, int *skycellID, double ra, double dec); 450 int MatchImageSkycellID (off_t meas, int cat, int myTessID, int myProjectionID, int mySkycellID); 451 452 int load_tess (char *treefile); 453 int get_tess_ids (int *tessID, int *projID, int *skycellID, double ra, double dec); 454 int TessellationIDsByImageName (int *tessID, int *projID, int *skycellID, char *name); 455 456 // int BoundaryTreePrimaryCell (char *primaryCellName, double ra, double dec); 457 // int BoundaryTreePrimaryCellIDs (int *projID, int *skycellID, double ra, double dec); 408 458 409 459 int print_measure_set_alt (Average *average, SecFilt *secfilt, Measure *measure); … … 417 467 int init_synthetic_mags (); 418 468 int add_synthetic_mags (AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, off_t *Nmeasure, off_t *Nm); 469 470 int relphot_parallel_regions (); 471 472 int assign_images (FITS_DB *db, RegionHostTable *regionHosts); 473 int select_images_hostregion (RegionHostTable *hosts, Image *image, off_t Nimage); 474 int find_host_for_coords (RegionHostTable *regionHosts, double R, double d); 475 int calculate_image_bounds (Image *image, double *rmin, double *rmax, double *dmin, double *dmax, double Rmid); 476 477 int launch_region_hosts (RegionHostTable *regionHosts); 478 int strextend (char *input, char *format,...); 479 480 Image *ImageTableLoad(char *filename, off_t *nimage); 481 int ImageTableSave (char *filename, Image *images, off_t Nimages); 482 483 int indexCatalogs (Catalog *catalog, int Ncatalog); 484 int catID_and_objID_to_seq (int catID, int objID, int *catSeq, off_t *objSeq); 485 486 int check_sync_file (char *filename, int nloop); 487 int clear_sync_file (char *filename); 488 int update_sync_file (char *filename, int nloop); 489 char *make_filename (char *dirname, char *hostname, int hostID, char *tailname); 490 491 int share_mean_mags (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop); 492 int slurp_mean_mags (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop); 493 int set_mean_mags (MeanMag *meanmags, AverageTiny *average, SecFilt *secfilt, int Nsec); 494 MeanMag *merge_mean_mags (MeanMag *target, int *ntarget, MeanMag *source, int Nsource); 495 496 MeanMag *MeanMagLoad(char *filename, off_t *nmeanmags); 497 int MeanMagSave(char *filename, MeanMag *meanmags, off_t Nmeanmags); 498 499 int share_image_mags (RegionHostTable *regionHosts, int nloop); 500 int slurp_image_mags (RegionHostTable *regionHosts, int nloop); 501 int set_image_mags (ImageMag *image_mags, Image *image); 502 ImageMag *merge_image_mags (ImageMag *target, int *ntarget, ImageMag *source, int Nsource); 503 504 ImageMag *ImageMagLoad(char *filename, off_t *nimage_mags); 505 int ImageMagSave(char *filename, ImageMag *image_mags, off_t Nimage_mags); 506 507 int markObjects (Catalog *catalog, int Ncatalog); 508 509 int relphot_parallel_images (); 510 int relphot_parallel_regions (); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/BoundaryTreeOps.c
r35759 r36680 1 1 # include "relphot.h" 2 2 3 // XXX for the moment, only load one boundary tree at a time 4 // XXX in fact, only allow RINGS.V3... 3 static int Ntess = 0; 4 static TessellationTable *tess = NULL; 5 5 6 static BoundaryTree *tree = NULL; 6 int TessellationIDsByImageName (int *tessID, int *projID, int *skycellID, char *name) { 7 7 8 int BoundaryTreePrimaryCell (char *primaryCellName, double ra, double dec) { 8 int i; 9 9 10 int zone, band; 11 12 if (!primaryCellName) return FALSE; 13 14 primaryCellName[0] = 0; 15 16 if (!tree) return FALSE; 17 18 if (!BoundaryTreeCellCoords (tree, &zone, &band, ra, dec)) { 19 fprintf (stderr, "mismatch!\n"); 20 return FALSE; 21 } 22 23 # define USE_PROJECTION_CELL 0 24 # if (USE_PROJECTION_CELL) 25 snprintf (primaryCellName, DVO_MAX_PATH, "RINGS.V3.%s", tree->name[zone][band]); 26 # else 27 28 // I have ra, dec, and the primary projection cell. In order to choose the primary skycell, 29 // I just need to project to ra,dec to X,Y based on the center of the cell and then get the subdivision right. 30 31 double x = 0.0; 32 double y = 0.0; 33 BoundaryTreeProjection (&x, &y, ra, dec, tree, zone, band); 34 35 int xi = x / tree->dX[zone][band]; 36 int yi = y / tree->dY[zone][band]; 37 int N = xi + tree->NX_SUB * yi; 38 39 // XXX short-circuit this for now (we should use this code if we make tree have more variable NX,NY values 40 // char format[24], skycellname[128]; 41 // int Ndigit = (int)(log10(tree->NX_SUB*tree->NY_SUB)) + 1 ; 42 // snprintf (format, 24, "%s.%%0%dd", tree->name[zone][band], Ndigit); 43 // snprintf (skycellname, 128, format, N); 44 45 snprintf (primaryCellName, DVO_MAX_PATH, "RINGS.V3.%s.%03d", tree->name[zone][band], N); 46 # endif 47 48 return TRUE; 49 } 50 51 int BoundaryTreePrimaryCellIDs (int *projID, int *skycellID, double ra, double dec) { 52 53 int zone, band; 54 10 *tessID = -1; 55 11 *projID = -1; 56 12 *skycellID = -1; 57 13 58 if (!t ree) return FALSE;14 if (!tess) return FALSE; 59 15 60 if (!BoundaryTreeCellCoords (tree, &zone, &band, ra, dec)) { 61 fprintf (stderr, "mismatch!\n"); 62 return FALSE; 16 for (i = 0; i < Ntess; i++) { 17 // do this with a strhash of some kind? 18 if (!strncmp (name, tess[i].basename, tess[i].Nbasename)) { 19 *tessID = i; 20 if (tess[i].projectIDoff >= 0) { 21 *projID = atoi(&name[tess[i].projectIDoff]); 22 } else { 23 *projID = 0; 24 } 25 if (tess[i].skycellIDoff >= 0) { 26 *skycellID = atoi(&name[tess[i].skycellIDoff]); 27 } else { 28 *skycellID = 0; 29 } 30 return TRUE; 31 } 63 32 } 64 65 // I have ra, dec, and the primary projection cell. In order to choose the primary skycell, 66 // I just need to project to ra,dec to X,Y based on the center of the cell and then get the subdivision right. 67 68 double x = 0.0; 69 double y = 0.0; 70 BoundaryTreeProjection (&x, &y, ra, dec, tree, zone, band); 71 72 int xi = x / tree->dX[zone][band]; 73 int yi = y / tree->dY[zone][band]; 74 int N = xi + tree->NX_SUB * yi; 75 76 *projID = tree->projID[zone][band]; 77 *skycellID = N; 78 79 return TRUE; 33 return FALSE; 80 34 } 81 35 82 int load_t ree (char *treefile) {36 int load_tess (char *tessfile) { 83 37 84 t ree = BoundaryTreeLoad (treefile);85 if (!t ree) {86 fprintf (stderr, "failed to load boundary tree %s\n", treefile);38 tess = TessellationTableLoad (tessfile, &Ntess); 39 if (!tess) { 40 fprintf (stderr, "failed to load tessellation boundary file %s\n", tessfile); 87 41 exit (2); 88 42 } … … 90 44 return TRUE; 91 45 } 46 47 int get_tess_ids (int *tessID, int *projID, int *skycellID, double ra, double dec) { 48 49 int status; 50 51 if (!tess) return FALSE; 52 53 status = TessellationPrimaryCellIDs(tess, Ntess, tessID, projID, skycellID, ra, dec); 54 return status; 55 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/BrightCatalog.c
r33651 r36680 101 101 measure[i].catID = catID[i]; 102 102 measure[i].photcode = photcode[i]; 103 measure[i].myDet = FALSE; 103 104 } 104 105 fprintf (stderr, "loaded data for %lld measure\n", (long long) Nrow); … … 141 142 GET_COLUMN(flags, "FLAGS", int); 142 143 GET_COLUMN(catID, "CAT_ID", int); 144 GET_COLUMN(objID, "OBJ_ID", int); 143 145 gfits_free_header (&theader); 144 146 gfits_free_table (&ftable); … … 153 155 average[i].flags = flags[i]; 154 156 average[i].catID = catID[i]; 157 average[i].objID = objID[i]; 158 average[i].nOwn = 0; 155 159 } 156 160 fprintf (stderr, "loaded data for %lld average\n", (long long) Nrow); … … 162 166 free (flags ); 163 167 free (catID ); 168 free (objID ); 164 169 165 170 catalog->average = average; … … 370 375 gfits_define_bintable_column (&theader, "J", "FLAGS", "flags", NULL, 1.0, 0.0); 371 376 gfits_define_bintable_column (&theader, "J", "CAT_ID", "catalog ref", NULL, 1.0, 0.0); 377 gfits_define_bintable_column (&theader, "J", "OBJ_ID", "object ref", NULL, 1.0, 0.0); 372 378 373 379 // generate the output array that carries the data … … 381 387 int *flags ; ALLOCATE (flags, int, catalog->Naverage); 382 388 int *catID ; ALLOCATE (catID, int, catalog->Naverage); 389 int *objID ; ALLOCATE (objID, int, catalog->Naverage); 383 390 384 391 // assign the storage arrays … … 391 398 flags[i] = average[i].flags; 392 399 catID[i] = average[i].catID; 400 objID[i] = average[i].objID; 393 401 } 394 402 … … 400 408 gfits_set_bintable_column (&theader, &ftable, "FLAGS", flags, catalog->Naverage); 401 409 gfits_set_bintable_column (&theader, &ftable, "CAT_ID", catID, catalog->Naverage); 410 gfits_set_bintable_column (&theader, &ftable, "OBJ_ID", objID, catalog->Naverage); 402 411 403 412 free (R ); … … 407 416 free (flags ); 408 417 free (catID ); 418 free (objID ); 409 419 410 420 gfits_fwrite_Theader (f, &theader); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/ImageOps.c
r35759 r36680 48 48 // stack image. for now, we generate these ID arrays based on the image names when we load in the image table (initImages). 49 49 // When we pass data to the remote clients via the ImageSubset, the projID/skycellID values are carried directly in the table. 50 int *tessID = NULL; 50 51 int *projectID = NULL; 51 52 int *skycellID = NULL; … … 81 82 82 83 // for stack images, assign projection cell ID and skycell ID based on filenames 84 ALLOCATE (tessID, int, Nimage); 83 85 ALLOCATE (projectID, int, Nimage); 84 86 ALLOCATE (skycellID, int, Nimage); … … 87 89 imageIdx[i] = i; 88 90 imageIDs[i] = image[i].imageID; 91 92 tessID[i] = -1; 89 93 projectID[i] = -1; 90 94 skycellID[i] = -1; 91 if (!strncmp (image[i].name, "RINGS.V3.skycell", strlen("RINGS.V3.skycell"))) { 92 projectID[i] = atoi(&image[i].name[17]); 93 skycellID[i] = atoi(&image[i].name[22]); 94 } 95 96 TessellationIDsByImageName (&tessID[i], &projectID[i], &skycellID[i], image[i].name); 95 97 } 96 98 97 99 // sort the image index by the IDs 100 // XXX does this break the imageID <-> projectID, etc match? 98 101 llsortpair (imageIDs, imageIdx, Nimage); 99 102 } … … 106 109 // create full a Image array and save the needed values 107 110 ALLOCATE (image, Image, N); 111 112 ALLOCATE (tessID, int, N); 108 113 ALLOCATE (projectID, int, N); 109 114 ALLOCATE (skycellID, int, N); … … 118 123 image[i].trate = input[i].trate ; 119 124 image[i].ubercalDist = input[i].ubercalDist ; 125 tessID[i] = input[i].tessID ; 120 126 projectID[i] = input[i].projID ; 121 127 skycellID[i] = input[i].skycellID ; … … 153 159 subset[i].trate = image[i].trate ; 154 160 subset[i].ubercalDist = image[i].ubercalDist ; 161 subset[i].tessID = tessID[i]; 155 162 subset[i].projID = projectID[i]; 156 163 subset[i].skycellID = skycellID[i]; … … 237 244 238 245 int Nmatch = 0; 239 for (i = 0; i < Ncatalog; i++) {246 for (i = 0; i < Ncatalog; i++) { 240 247 for (j = 0; j < catalog[i].Nmeasure; j++) { 248 catalog[i].measureT[j].myDet = FALSE; // a detetion is not mine until proven otherwise 241 249 ecode = GetPhotcodeEquivCodebyCode (catalog[i].measureT[j].photcode); 250 251 // skip measurements which do not match one of the requested photcodes ( 252 // (do we not already exclude in bcatalog -- maybe needed for reload_objects? 242 253 found = FALSE; 243 254 for (Ns = 0; !found && (Ns < Nphotcodes); Ns++) { … … 245 256 } 246 257 if (!found) continue; 258 259 // if we match one of our images, myDet gets set to TRUE 247 260 matchImage (catalog, j, i, doImageList); 248 261 Nmatch ++; … … 315 328 return; 316 329 } 330 catalog[cat].measureT[meas].myDet = TRUE; 317 331 318 332 if (USE_GRID) { … … 461 475 462 476 // returns image.Mcal - ff(x,y) 463 int MatchImageSkycellID (off_t meas, int cat, int my ProjectionID, int mySkycellID) {477 int MatchImageSkycellID (off_t meas, int cat, int myTessID, int myProjectionID, int mySkycellID) { 464 478 465 479 off_t i; … … 470 484 if (i == -1) return FALSE; 471 485 486 if (tessID[i] == -1) return FALSE; 472 487 if (projectID[i] == -1) return FALSE; 473 488 if (skycellID[i] == -1) return FALSE; 474 489 490 if (tessID[i] != myTessID) return FALSE; 475 491 if (projectID[i] != myProjectionID) return FALSE; 476 492 if (skycellID[i] != mySkycellID) return FALSE; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/ImageSubset.c
r35759 r36680 63 63 GET_COLUMN (map, "PHOTOM_MAP", int); 64 64 GET_COLUMN (flags, "FLAGS", int); 65 GET_COLUMN (tessID, "TESS_ID", int); 65 66 GET_COLUMN (projID, "PROJ_ID", int); 66 67 GET_COLUMN (skycellID, "SKYCELL_ID", int); … … 78 79 image[i].photom_map_id = map[i]; 79 80 image[i].flags = flags[i]; 81 image[i].tessID = tessID[i]; 80 82 image[i].projID = projID[i]; 81 83 image[i].skycellID = skycellID[i]; … … 91 93 free (map); 92 94 free (flags); 95 free (tessID); 93 96 free (projID); 94 97 free (skycellID); … … 130 133 gfits_define_bintable_column (&theader, "J", "FLAGS", "flags", NULL, 1.0, 1.0*0x8000); 131 134 135 gfits_define_bintable_column (&theader, "J", "TESS_ID", "ID", NULL, 1.0, 0.0); 132 136 gfits_define_bintable_column (&theader, "J", "PROJ_ID", "ID", NULL, 1.0, 0.0); 133 137 gfits_define_bintable_column (&theader, "J", "SKYCELL_ID", "ID", NULL, 1.0, 0.0); … … 143 147 float *Mcal, *dMcal; 144 148 unsigned int *imageID, *map, *flags, *tzero; 145 int * projID, *skycellID;149 int *tessID, *projID, *skycellID; 146 150 unsigned short *trate; 147 151 short *ucdist; … … 153 157 ALLOCATE (map, unsigned int, Nimage); 154 158 ALLOCATE (flags, unsigned int, Nimage); 159 ALLOCATE (tessID, int, Nimage); 155 160 ALLOCATE (projID, int, Nimage); 156 161 ALLOCATE (skycellID, int, Nimage); … … 169 174 trate[i] = image[i].trate; 170 175 ucdist[i] = image[i].ubercalDist; 176 tessID[i] = image[i].tessID; 171 177 projID[i] = image[i].projID; 172 178 skycellID[i] = image[i].skycellID; … … 179 185 gfits_set_bintable_column (&theader, &ftable, "PHOTOM_MAP", map, Nimage); 180 186 gfits_set_bintable_column (&theader, &ftable, "FLAGS", flags, Nimage); 187 gfits_set_bintable_column (&theader, &ftable, "TESS_ID", tessID, Nimage); 181 188 gfits_set_bintable_column (&theader, &ftable, "PROJ_ID", projID, Nimage); 182 189 gfits_set_bintable_column (&theader, &ftable, "SKYCELL_ID", skycellID, Nimage); … … 190 197 free (map); 191 198 free (flags); 199 free (tessID); 192 200 free (projID); 193 201 free (skycellID); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/MosaicOps.c
r35806 r36680 320 320 } 321 321 322 /* find mosaic frames (unique time periods) (NOTE : we do NOT require matching photcodes but we 323 match images by MOSAICNAME. this last point is weak: it forces a single camera at a time. 324 we can extend the logic to multiple cameras if we make list of MOSAICNAMES (better to assign a camera ID) 325 */ 326 void makeMosaics (Image *image, off_t Nimage) { 327 328 off_t i, j, status, found, NMOSAIC, *MosaicN_IMAGE; 329 unsigned int start, stop, *startTimes, *startTimesMosaic; 330 char *pname; 331 332 if (!MOSAIC_ZEROPT) return; 333 334 INITTIME; 335 336 /* a 'mosaic' in relphot is (unlike relastro) a virtual concept: there is no 337 * entry in the image table that represents this mosaic. Instead, it is an 338 * internal construct that defines a group of related images 339 */ 340 341 // generate a list of all image start times 342 ALLOCATE (startTimes, unsigned int, Nimage); 343 for (i = 0; i < Nimage; i++) { 344 startTimes[i] = image[i].tzero; 345 } 346 sort_times (startTimes, Nimage); 347 MARKTIME("create array of all image obstimes: %f sec\n", dtime); 348 349 Nmosaic = 0; 350 NMOSAIC = 1000; 351 ALLOCATE (startTimesMosaic, unsigned int, NMOSAIC); 352 startTimesMosaic[0] = startTimes[0]; 353 354 // generate a list of the unique start times (these define the mosaics) 355 for (i = 0; i < Nimage; i++) { 356 if (startTimes[i] < startTimesMosaic[Nmosaic]) { 357 fprintf (stderr, "error?\n"); 358 abort(); 359 } 360 if (startTimes[i] == startTimesMosaic[Nmosaic]) continue; 361 Nmosaic ++; 362 if (Nmosaic >= NMOSAIC) { 363 NMOSAIC += 1000; 364 REALLOCATE (startTimesMosaic, unsigned int, NMOSAIC); 365 } 366 startTimesMosaic[Nmosaic] = startTimes[i]; 367 } 368 Nmosaic ++; 369 MARKTIME("create array of mosaic obstimes: %f sec\n", dtime); 370 371 // now I have a list of uniq start times, and they are in order 372 // create the mosaic arrays for these times 373 ALLOCATE (mosaic, Mosaic, Nmosaic); 374 375 ALLOCATE (MosaicToImage, off_t *, Nmosaic); 376 ALLOCATE (MosaicN_Image, off_t, Nmosaic); 377 ALLOCATE (MosaicN_IMAGE, off_t, Nmosaic); 378 379 // init the mosaic array values 380 for (i = 0; i < Nmosaic; i++) { 381 mosaic[i].start = startTimesMosaic[i]; 382 mosaic[i].stop = 0; 383 mosaic[i].Mcal = 0.0; 384 mosaic[i].dMcal = 0.0; 385 mosaic[i].dMsys = 0.0; 386 mosaic[i].Xm = 0.0; 387 mosaic[i].flags = 0; 388 mosaic[i].secz = NAN; 389 mosaic[i].photcode = 0; 390 mosaic[i].skipCal = FALSE; 391 392 memset (&mosaic[i].coords, 0, sizeof(Coords)); 393 394 MosaicN_IMAGE[i] = 10; 395 MosaicN_Image[i] = 0; 396 ALLOCATE (MosaicToImage[i], off_t, MosaicN_IMAGE[i]); 397 MosaicToImage[i][0] = -1; 398 } 399 400 ALLOCATE (ImageToMosaic, off_t, Nimage); // mosaic to which image belongs 401 402 // assign each image to a mosaic 403 for (i = 0; i < Nimage; i++) { 404 ImageToMosaic[i] = -1; 405 406 /* select valid mosaic images by photcode */ 407 pname = GetPhotcodeNamebyCode (image[i].photcode); 408 if (!pname) continue; 409 410 status = strncmp (pname, MOSAICNAME, strlen (MOSAICNAME)); 411 if (status) continue; 412 413 start = image[i].tzero; 414 stop = image[i].tzero + MAX(1.01*image[i].trate*image[i].NY, 1); 415 416 j = findMosaic(startTimesMosaic, Nmosaic, start); 417 if (j == -1) { 418 fprintf (stderr, "programming error? all image images should belong to a mosaic\n"); 419 abort(); 420 } 421 422 // add reference from image to mosaic 423 ImageToMosaic[i] = j; 424 425 // have we already found this mosaic? 426 found = (MosaicN_Image[j] > 0); 427 428 /* add image to mosaic image list */ 429 MosaicToImage[j][MosaicN_Image[j]] = i; 430 MosaicN_Image[j] ++; 431 if (MosaicN_Image[j] == MosaicN_IMAGE[j]) { 432 MosaicN_IMAGE[j] += 10; 433 REALLOCATE (MosaicToImage[j], off_t, MosaicN_IMAGE[j]); 434 } 435 if (found) continue; 436 437 /* a new mosaic, define ranges */ 438 if (mosaic[j].start != start) { 439 fprintf (stderr, "error?\n"); 440 abort(); 441 } 442 mosaic[j].stop = stop; 443 mosaic[j].Mcal = 0.0; 444 mosaic[j].dMcal = 0.0; 445 mosaic[j].Xm = 0.0; 446 mosaic[j].dMsys = image[i].flags; 447 mosaic[j].flags = image[i].flags; 448 mosaic[j].secz = image[i].secz; 449 mosaic[j].photcode = GetPhotcodeEquivCodebyCode (image[i].photcode); 450 } 451 MARKTIME("assign images to mosaic: %f sec\n", dtime); 452 453 // free this or not? 454 free (MosaicN_IMAGE); 455 free (startTimes); 456 free (startTimesMosaic); 457 458 fprintf (stderr, "matched %d images to %d mosaics\n", (int) Nimage, (int) Nmosaic); 459 460 return; 461 } 462 463 Mosaic *getMosaicForImage (off_t im) { 464 465 if (im < 0) return NULL; 466 if (!ImageToMosaic) return NULL; 467 468 off_t m = ImageToMosaic[im]; 469 if (m < 0) return NULL; 470 if (m >= Nmosaic) return NULL; 471 472 return (&mosaic[m]); 473 } 474 322 475 // use bisection to find the overlapping mosaic (returns exact match) 323 476 // startTimes is a sorted, unique list of times … … 350 503 } 351 504 return (-1); 505 } 506 507 void setMosaicCenters (Image *image, off_t Nimage) { 508 509 /* find max dR, dD range for all mosaics */ 510 /* define mosaic.coords to cover dR, dD */ 511 /* send results to initGridBins */ 512 513 off_t i, j, m, NX, NY, NC, Nc; 514 double R, D, Rmid, Dmid; 515 double Mcal, dMcal, Xm; 516 double *Rc, *Dc; 517 518 NC = 100; 519 ALLOCATE (Rc, double, NC); 520 ALLOCATE (Dc, double, NC); 521 522 for (i = 0; i < Nmosaic; i++) { 523 Nc = 0; 524 Rmid = Dmid = NAN; 525 Mcal = dMcal = Xm = 0; 526 for (j = 0; j < MosaicN_Image[i]; j++) { 527 m = MosaicToImage[i][j]; 528 529 if (!FindMosaicForImage (image, Nimage, m)) { 530 if (VERBOSE2) fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i); 531 continue; 532 } 533 534 NX = image[m].NX; 535 NY = image[m].NY; 536 XY_to_RD (&R, &D, 0.5*NX, 0.5*NY, &image[m].coords); 537 R = ohana_normalize_angle_to_midpoint (R, 180.0); 538 539 // Exclude images with crazy astrometry 540 // XXX NOTE : this is gpc1-specific 541 { 542 double dP1 = hypot(image[m].coords.pc1_1, image[m].coords.pc1_2); 543 double dP2 = hypot(image[m].coords.pc2_1, image[m].coords.pc2_2); 544 if (fabs(dP1 - 1.0) > 0.02) continue; 545 if (fabs(dP2 - 1.0) > 0.02) continue; 546 547 double X00, Y00, X10, Y10, X01, Y01; 548 XY_to_LM (&X00, &Y00, 0.0, 0.0, &image[m].coords); 549 XY_to_LM (&X10, &Y10, image[m].NX, 0.0, &image[m].coords); 550 XY_to_LM (&X01, &Y01, 0.0, image[m].NY, &image[m].coords); 551 double dS0 = hypot ((X00 - X10), (Y00 - Y10)); 552 double dS1 = hypot ((X00 - X01), (Y00 - Y01)); 553 if (dS0 > 6000) continue; 554 if (dS1 > 6500) continue; 555 } 556 557 Rc[Nc] = R; 558 Dc[Nc] = D; 559 Nc ++; 560 if (Nc >= NC) { 561 NC += 100; 562 REALLOCATE (Rc, double, NC); 563 REALLOCATE (Dc, double, NC); 564 } 565 566 Mcal += image[m].Mcal; 567 dMcal += image[m].dMcal; 568 Xm += image[m].Xm; 569 570 // for ubercal images, we (elsewhere) keep Mcal frozen 571 572 /* we are using mosaic.Mcal, not image.Mcal. reset image.Mcal */ 573 image[m].Mcal = 0.0; 574 image[m].dMcal = NAN; 575 image[m].Xm = NAN_S_SHORT; 576 } 577 578 if (Nc > 0) { 579 dsort (Rc, Nc); 580 if (Rc[Nc-1] - Rc[0] > 180.0) { 581 // in our list, Rc is in the range 0.0 to 360.0. 582 // any mosaic which is close to the 0.0, 360.0 boundary may have some on 583 // one side or the other. count how many have values more than Rc[0] + 180. 584 // if more than half are at the large end, re-normalize to that range 585 int Nbig = 0; 586 for (j = 1; j < Nc; j++) { 587 if (Rc[j] - Rc[0] > 180.0) Nbig ++; 588 } 589 if (Nbig > 0.5*Nc) { 590 for (j = 0; j < Nc; j++) { 591 Rc[j] = ohana_normalize_angle_to_midpoint (Rc[j], 360.0); 592 } 593 dsort (Rc, Nc); 594 } else if (Nbig > 0) { 595 for (j = 0; j < Nc; j++) { 596 Rc[j] = ohana_normalize_angle_to_midpoint (Rc[j], 0.0); 597 } 598 dsort (Rc, Nc); 599 } 600 } 601 dsort (Dc, Nc); 602 603 Rmid = Rc[(int)(0.5*Nc)]; 604 Dmid = Dc[(int)(0.5*Nc)]; 605 } 606 607 strcpy (mosaic[i].coords.ctype, "DEC--TAN"); 608 mosaic[i].coords.crval1 = Rmid; 609 mosaic[i].coords.crval2 = Dmid; 610 mosaic[i].coords.crpix1 = 0.0; 611 mosaic[i].coords.crpix2 = 0.0; 612 mosaic[i].coords.cdelt1 = 1.0 / 3600.0; 613 mosaic[i].coords.cdelt2 = 1.0 / 3600.0; 614 mosaic[i].coords.pc1_1 = 1.0; 615 mosaic[i].coords.pc2_2 = 1.0; 616 mosaic[i].coords.pc1_2 = 0.0; 617 mosaic[i].coords.pc2_1 = 0.0; 618 619 mosaic[i].Mcal = Mcal / MosaicN_Image[i]; 620 mosaic[i].dMcal = dMcal / MosaicN_Image[i]; 621 mosaic[i].Xm = Xm / MosaicN_Image[i]; 622 } 623 return; 352 624 } 353 625 … … 412 684 } 413 685 dS /= MosaicN_Image[i]; 414 strcpy (mosaic[i].coords.ctype, " RA---TAN");686 strcpy (mosaic[i].coords.ctype, "DEC--TAN"); 415 687 mosaic[i].coords.crval1 = Rmin; 416 688 mosaic[i].coords.crval2 = Dmin; … … 527 799 528 800 if (!MOSAIC_ZEROPT) return (FALSE); 801 // if we are calibrating by mosaic, redefine myDet == on one of my mosaics 529 802 530 803 int Nmatch = 0; 531 804 for (i = 0; i < Ncatalog; i++) { 532 805 for (j = 0; j < catalog[i].Nmeasure; j++) { 806 catalog[i].measureT[j].myDet = FALSE; // a detetion is not mine until proven otherwise 807 533 808 if (TimeSelect) { 534 809 if (catalog[i].measureT[j].t < TSTART) continue; … … 582 857 } 583 858 859 // this measurement is on one of my mosaics, mark it as mine. 860 catalog[cat].measureT[meas].myDet = TRUE; 584 861 MeasureToMosaic[cat][meas] = mosID; 585 862 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/StarOps.c
r35759 r36680 63 63 results->Ngrid = 0; 64 64 if (allocLists) { 65 ALLOCATE (results-> list,double, Nmax);66 ALLOCATE (results->d list, double, Nmax);67 ALLOCATE (results->w list, double, Nmax);65 ALLOCATE (results->Mpsflist, double, Nmax); 66 ALLOCATE (results->dpsflist, double, Nmax); 67 ALLOCATE (results->wpsflist, double, Nmax); 68 68 } 69 69 } 70 70 71 71 void SetMrelInfoFree (SetMrelInfo *results) { 72 free (results-> list);73 free (results->d list);74 free (results->w list);72 free (results->Mpsflist); 73 free (results->dpsflist); 74 free (results->wpsflist); 75 75 } 76 76 77 77 void SetMrelInfoAccum (SetMrelInfo *summary, SetMrelInfo *results) { 78 78 summary->Nfew += results->Nfew ; 79 summary->Ncode += results->Ncode ;79 summary->Ncode += results->Ncode ; 80 80 summary->Nsys += results->Nsys ; 81 81 summary->Nbad += results->Nbad ; … … 158 158 SetMrelInfoInit (&summary, FALSE); 159 159 SetMrelInfoInit (&results, TRUE); // allocates results->list,dlist,wlist 160 ALLOCATE (results.aplist, double, Nmax); 161 ALLOCATE (results.kronlist, double, Nmax); 160 161 ALLOCATE (results.Maplist, double, Nmax); 162 ALLOCATE (results.daplist, double, Nmax); 163 ALLOCATE (results.waplist, double, Nmax); 164 165 ALLOCATE (results.Mkronlist, double, Nmax); 162 166 ALLOCATE (results.dkronlist, double, Nmax); 167 ALLOCATE (results.wkronlist, double, Nmax); 163 168 164 169 ALLOCATE (results.psfqf_list, double, Nmax); … … 183 188 184 189 SetMrelInfoFree (&results); 185 free (results.aplist); 186 free (results.kronlist); 190 free (results.Maplist); 191 free (results.daplist); 192 free (results.waplist); 193 194 free (results.Mkronlist); 187 195 free (results.dkronlist); 196 free (results.wkronlist); 188 197 189 198 free (results.psfqf_list); … … 328 337 int setMrel_catalog (Catalog *catalog, int Nc, int pass, FlatCorrectionTable *flatcorr, SetMrelInfo *results, int Nsecfilt) { 329 338 339 fprintf (stderr, "??? should you still be using the old version of setMrel_catalog??\n"); 340 exit (3); 341 342 # if (0) 343 330 344 off_t j, k, m, ID; 331 345 int N; … … 333 347 334 348 StatType stats, apstats, kronstats; 335 liststats_setmode (& stats, STATMODE);349 liststats_setmode (&psfstats, STATMODE); 336 350 liststats_setmode (&apstats, STATMODE); 337 351 liststats_setmode (&kronstats, STATMODE); … … 366 380 if (isSetMrelFinal) { 367 381 // set the name of the primary skycell (this is used in a strcmp to match the skycells in stack detections) 368 BoundaryTreePrimaryCell(primaryCell, catalog[Nc].average[j].R, catalog[Nc].average[j].D); 382 // XXX : this whole function is deprecated 383 // BoundaryTreePrimaryCell(primaryCell, catalog[Nc].average[j].R, catalog[Nc].average[j].D); 369 384 } 370 385 … … 833 848 if (primaryCell) free (primaryCell); 834 849 return (TRUE); 850 # endif 835 851 } 836 852 … … 890 906 } 891 907 return (TRUE); 908 } 909 910 int markObjects (Catalog *catalog, int Ncatalog) { 911 912 int i, n; 913 off_t j; 914 915 // How strongly do I own this object? 916 for (i = 0; i < Ncatalog; i++) { 917 for (j = 0; j < catalog[i].Naverage; j++) { 918 int nOwn = 0; 919 int m = catalog[i].averageT[j].measureOffset; 920 for (n = 0; n < catalog[i].averageT[j].Nmeasure; n++) { 921 if (!catalog[i].measureT[m+n].myDet) continue; 922 nOwn ++; 923 } 924 catalog[i].averageT[j].nOwn = nOwn; 925 } 926 } 927 return TRUE; 928 } 929 930 int dumpObjects (char *filename, Catalog *catalog, int Ncatalog) { 931 932 int i, n; 933 off_t j; 934 935 FILE *ftest = fopen (filename, "w"); 936 937 for (i = 0; i < Ncatalog; i++) { 938 for (j = 0; j < catalog[i].Naverage; j++) { 939 int m = catalog[i].averageT[j].measureOffset; 940 for (n = 0; n < catalog[i].averageT[j].Nmeasure; n++) { 941 fprintf (ftest, "%08x %08x %10.6f %10.6f %3d %1d\n", catalog[i].averageT[j].catID, catalog[i].averageT[j].objID, catalog[i].averageT[j].R, catalog[i].averageT[j].D, catalog[i].averageT[j].Nmeasure, catalog[i].measureT[m+n].myDet); 942 } 943 } 944 } 945 fclose (ftest); 946 return TRUE; 892 947 } 893 948 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/args.c
r35806 r36680 1 1 # include "relphot.h" 2 2 3 intargs (int argc, char **argv) {3 RelphotMode args (int argc, char **argv) { 4 4 5 5 int N; 6 6 double trange; 7 8 /* define time */ 9 TimeSelect = FALSE; 10 if ((N = get_argument (argc, argv, "-time"))) { 11 remove_argument (N, &argc, argv); 12 if (!ohana_str_to_time (argv[N], &TSTART)) { 13 fprintf (stderr, "ERROR: syntax error\n"); 14 return (MODE_ERROR); 15 } 16 remove_argument (N, &argc, argv); 17 if (!ohana_str_to_dtime (argv[N], &trange)) { 18 if (!ohana_str_to_time (argv[N], &TSTOP)) { 19 fprintf (stderr, "ERROR: syntax error\n"); 20 return (MODE_ERROR); 21 } 22 } else { 23 if (trange < 0) { 24 trange = fabs (trange); 25 TSTOP = TSTART; 26 TSTART -= trange; 27 } else { 28 TSTOP = TSTART + trange; 29 } 30 } 31 remove_argument (N, &argc, argv); 32 TimeSelect = TRUE; 33 } 34 35 /* specify portion of the sky */ 36 UserPatch.Rmin = 0; 37 UserPatch.Rmax = 360; 38 UserPatch.Dmin = -90; 39 UserPatch.Dmax = +90; 40 if ((N = get_argument (argc, argv, "-region"))) { 41 remove_argument (N, &argc, argv); 42 UserPatch.Rmin = atof (argv[N]); 43 remove_argument (N, &argc, argv); 44 UserPatch.Rmax = atof (argv[N]); 45 remove_argument (N, &argc, argv); 46 UserPatch.Dmin = atof (argv[N]); 47 remove_argument (N, &argc, argv); 48 UserPatch.Dmax = atof (argv[N]); 49 remove_argument (N, &argc, argv); 50 } 51 52 /* specify region file by name (eg n0000/0000.00) */ 53 UserCatalog = NULL; 54 if ((N = get_argument (argc, argv, "-catalog"))) { 55 remove_argument (N, &argc, argv); 56 UserCatalog = strcreate (argv[N]); 57 remove_argument (N, &argc, argv); 58 } 59 60 USE_BASIC_CHECK = FALSE; 61 if ((N = get_argument (argc, argv, "-basic-image-search"))) { 62 remove_argument (N, &argc, argv); 63 USE_BASIC_CHECK = TRUE; 64 } 65 66 USE_FULL_OVERLAP = TRUE; 67 if ((N = get_argument (argc, argv, "-sloppy-image-overlap"))) { 68 remove_argument (N, &argc, argv); 69 USE_FULL_OVERLAP = FALSE; 70 } 71 72 SET_MREL_VERSION = 1; 73 if ((N = get_argument (argc, argv, "-set-mrel-version"))) { 74 remove_argument (N, &argc, argv); 75 SET_MREL_VERSION = atof(argv[N]); 76 remove_argument (N, &argc, argv); 77 } 78 79 VERBOSE = VERBOSE2 = FALSE; 80 if ((N = get_argument (argc, argv, "-v"))) { 81 VERBOSE = TRUE; 82 remove_argument (N, &argc, argv); 83 } 84 if ((N = get_argument (argc, argv, "-vv"))) { 85 VERBOSE2 = VERBOSE = TRUE; 86 remove_argument (N, &argc, argv); 87 } 88 89 NTHREADS = 0; 90 if ((N = get_argument (argc, argv, "-threads"))) { 91 remove_argument (N, &argc, argv); 92 NTHREADS = atof (argv[N]); 93 remove_argument (N, &argc, argv); 94 } 95 96 // XXX for the moment, make this selection manual. it needs to be automatic 97 // based on the state of the SkyTable 98 HOST_ID = 0; 99 PARALLEL = FALSE; 100 if ((N = get_argument (argc, argv, "-parallel"))) { 101 PARALLEL = TRUE; 102 remove_argument (N, &argc, argv); 103 } 104 // this is a test mode : rather than launching the remote jobs and waiting for completion, 105 // relphot will simply list the remote command and wait for the user to signal completion 106 PARALLEL_MANUAL = FALSE; 107 if ((N = get_argument (argc, argv, "-parallel-manual"))) { 108 PARALLEL = TRUE; // -parallel-manual implies -parallel 109 PARALLEL_MANUAL = TRUE; 110 remove_argument (N, &argc, argv); 111 } 112 // this is a test mode : rather than launching the relphot_client jobs remotely, they are 113 // run in serial via 'system' 114 PARALLEL_SERIAL = FALSE; 115 if ((N = get_argument (argc, argv, "-parallel-serial"))) { 116 if (PARALLEL_MANUAL) { 117 fprintf (stderr, "ERROR: cannot mix -parallel-manual and -parallel-serial\n"); 118 exit (1); 119 } 120 PARALLEL = TRUE; // -parallel-serial implies -parallel 121 PARALLEL_SERIAL = TRUE; 122 remove_argument (N, &argc, argv); 123 } 124 125 PLOTSTUFF = FALSE; 126 if ((N = get_argument (argc, argv, "-plot"))) { 127 PLOTSTUFF = TRUE; 128 remove_argument (N, &argc, argv); 129 } 130 131 PLOTDELAY = 500000; 132 if ((N = get_argument (argc, argv, "-plotdelay"))) { 133 remove_argument (N, &argc, argv); 134 PLOTDELAY = 1e6*atof(argv[N]); 135 PLOTSTUFF = TRUE; // always turn on plotting if i request a plot delay 136 remove_argument (N, &argc, argv); 137 } 138 139 if ((N = get_argument (argc, argv, "-outroot"))) { 140 remove_argument (N, &argc, argv); 141 OUTROOT = strcreate (argv[N]); 142 remove_argument (N, &argc, argv); 143 } else { 144 OUTROOT = strcreate ("relphot"); 145 } 146 147 strcpy (STATMODE, "WT_MEAN"); 148 if ((N = get_argument (argc, argv, "-statmode"))) { 149 remove_argument (N, &argc, argv); 150 strcpy (STATMODE, argv[N]); 151 remove_argument (N, &argc, argv); 152 } 153 154 NLOOP = 8; 155 if ((N = get_argument (argc, argv, "-n"))) { 156 remove_argument (N, &argc, argv); 157 NLOOP = atof (argv[N]); 158 remove_argument (N, &argc, argv); 159 } 160 if ((N = get_argument (argc, argv, "-nloop"))) { 161 remove_argument (N, &argc, argv); 162 NLOOP = atof (argv[N]); 163 remove_argument (N, &argc, argv); 164 } 165 166 NGRID = 8; 167 if ((N = get_argument (argc, argv, "-ngrid"))) { 168 remove_argument (N, &argc, argv); 169 NGRID = atof (argv[N]); 170 remove_argument (N, &argc, argv); 171 } 172 173 RESET = FALSE; 174 if ((N = get_argument (argc, argv, "-reset"))) { 175 remove_argument (N, &argc, argv); 176 RESET = TRUE; 177 } 178 179 RESET_ZEROPTS = FALSE; 180 if ((N = get_argument (argc, argv, "-reset-zpts"))) { 181 remove_argument (N, &argc, argv); 182 RESET_ZEROPTS = TRUE; 183 } 184 185 UPDATE = FALSE; 186 if ((N = get_argument (argc, argv, "-update"))) { 187 remove_argument (N, &argc, argv); 188 UPDATE = TRUE; 189 } 190 191 UPDATE_CATFORMAT = NULL; 192 if ((N = get_argument (argc, argv, "-update-catformat"))) { 193 remove_argument (N, &argc, argv); 194 UPDATE_CATFORMAT = strcreate (argv[N]); 195 remove_argument (N, &argc, argv); 196 } 197 198 SAVE_IMAGE_UPDATES = TRUE; 199 if ((N = get_argument (argc, argv, "-skip-image-updates"))) { 200 remove_argument (N, &argc, argv); 201 SAVE_IMAGE_UPDATES = FALSE; 202 } 203 204 MaxDensityUse = FALSE; 205 if ((N = get_argument (argc, argv, "-max-density"))) { 206 remove_argument (N, &argc, argv); 207 MaxDensityValue = atof(argv[N]); 208 remove_argument (N, &argc, argv); 209 MaxDensityUse = TRUE; 210 } 211 212 CLOUD_TOLERANCE = 0.02; 213 if ((N = get_argument (argc, argv, "-cloud-limit"))) { 214 remove_argument (N, &argc, argv); 215 CLOUD_TOLERANCE = atof(argv[N]); 216 remove_argument (N, &argc, argv); 217 } 218 219 // XXX should we load a tree from CATDIR by default? 220 // NOTE: a given catdir needs an appropriate boundary tree 221 BOUNDARY_TREE = NULL; 222 if ((N = get_argument (argc, argv, "-boundary-tree"))) { 223 remove_argument (N, &argc, argv); 224 BOUNDARY_TREE = strcreate(argv[N]); 225 load_tess (BOUNDARY_TREE); 226 remove_argument (N, &argc, argv); 227 } 228 229 SHOW_PARAMS = FALSE; 230 if ((N = get_argument (argc, argv, "-params"))) { 231 remove_argument (N, &argc, argv); 232 SHOW_PARAMS = TRUE; 233 } 234 235 PlotMmin = 10.0; PlotMmax = 20.0; PlotdMmin = -1.0; PlotdMmax = 1.0; 236 if ((N = get_argument (argc, argv, "-plrange"))) { 237 remove_argument (N, &argc, argv); 238 PlotMmin = atof (argv[N]); 239 remove_argument (N, &argc, argv); 240 PlotMmax = atof (argv[N]); 241 remove_argument (N, &argc, argv); 242 PlotdMmin = atof (argv[N]); 243 remove_argument (N, &argc, argv); 244 PlotdMmax = atof (argv[N]); 245 remove_argument (N, &argc, argv); 246 } 247 248 /* XXX this argument used to do two things: specify the camera name and tell the analysis to 249 calculate a common zero point for a single mosaic. I've moved the MOSAICNAME concept into the 250 config system, but need to use this argument to specify that the mosaic zeropoints should be 251 calculated. */ 252 MOSAIC_ZEROPT = FALSE; 253 if ((N = get_argument (argc, argv, "-mosaic"))) { 254 remove_argument (N, &argc, argv); 255 MOSAIC_ZEROPT = TRUE; 256 if (!strcasecmp (MOSAICNAME, "none")) { 257 fprintf (stderr, "mosaic astrometry selected by MOSAICNAME not defined\n"); 258 exit (2); 259 } 260 } 261 262 FREEZE_IMAGES = FALSE; 263 if ((N = get_argument (argc, argv, "-imfreeze"))) { 264 remove_argument (N, &argc, argv); 265 FREEZE_IMAGES = TRUE; 266 } 267 268 FREEZE_MOSAICS = FALSE; 269 if ((N = get_argument (argc, argv, "-mosfreeze"))) { 270 remove_argument (N, &argc, argv); 271 FREEZE_MOSAICS = TRUE; 272 } 273 274 // USE_GRID is not valid for all cases, probably should be its own mode... 275 USE_GRID = FALSE; 276 if ((N = get_argument (argc, argv, "-grid"))) { 277 remove_argument (N, &argc, argv); 278 USE_GRID = TRUE; 279 } 280 281 KEEP_UBERCAL = TRUE; 282 if ((N = get_argument (argc, argv, "-reset-ubercal"))) { 283 remove_argument (N, &argc, argv); 284 KEEP_UBERCAL = FALSE; 285 } 286 287 MIN_ERROR = 0.001; 288 if ((N = get_argument (argc, argv, "-minerror"))) { 289 remove_argument (N, &argc, argv); 290 MIN_ERROR = atof (argv[N]); 291 remove_argument (N, &argc, argv); 292 /* require MIN_ERROR > 0 */ 293 } 294 295 AreaSelect = FALSE; 296 if ((N = get_argument (argc, argv, "-area"))) { 297 remove_argument (N, &argc, argv); 298 AreaXmin = atof (argv[N]); 299 remove_argument (N, &argc, argv); 300 AreaXmax = atof (argv[N]); 301 remove_argument (N, &argc, argv); 302 AreaYmin = atof (argv[N]); 303 remove_argument (N, &argc, argv); 304 AreaYmax = atof (argv[N]); 305 remove_argument (N, &argc, argv); 306 AreaSelect = TRUE; 307 } 308 309 ImagSelect = FALSE; 310 if ((N = get_argument (argc, argv, "-instmag"))) { 311 remove_argument (N, &argc, argv); 312 ImagMin = atof (argv[N]); 313 remove_argument (N, &argc, argv); 314 ImagMax = atof (argv[N]); 315 remove_argument (N, &argc, argv); 316 ImagSelect = TRUE; 317 } 318 319 DophotSelect = FALSE; 320 if ((N = get_argument (argc, argv, "-dophot"))) { 321 remove_argument (N, &argc, argv); 322 DophotValue = atof (argv[N]); 323 remove_argument (N, &argc, argv); 324 DophotSelect = TRUE; 325 } 326 327 SyntheticPhotometry = FALSE; 328 if ((N = get_argument (argc, argv, "-synthphot"))) { 329 remove_argument (N, &argc, argv); 330 SyntheticPhotometry = TRUE; 331 init_synthetic_mags(); 332 } 333 334 refPhotcode = NULL; 335 if ((N = get_argument (argc, argv, "-refcode"))) { 336 remove_argument (N, &argc, argv); 337 refPhotcode = GetPhotcodebyName (argv[N]); 338 if (!refPhotcode) { 339 fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", argv[N]); 340 exit (1); 341 } 342 remove_argument (N, &argc, argv); 343 } 344 345 REGION_FILE = NULL; 346 if ((N = get_argument (argc, argv, "-region-hosts"))) { 347 remove_argument (N, &argc, argv); 348 REGION_FILE = strcreate (argv[N]); 349 remove_argument (N, &argc, argv); 350 } 351 352 REGION_HOST_ID = 0; 353 if ((N = get_argument (argc, argv, "-region-hostID"))) { 354 remove_argument (N, &argc, argv); 355 REGION_HOST_ID = atoi (argv[N]); 356 remove_argument (N, &argc, argv); 357 } 358 359 RelphotMode mode = MODE_ERROR; 360 if ((N = get_argument (argc, argv, "-images"))) { 361 remove_argument (N, &argc, argv); 362 mode = UPDATE_IMAGES; 363 } 364 if ((N = get_argument (argc, argv, "-averages"))) { 365 remove_argument (N, &argc, argv); 366 mode = UPDATE_AVERAGES; 367 } 368 if ((N = get_argument (argc, argv, "-apply-offsets"))) { 369 remove_argument (N, &argc, argv); 370 mode = APPLY_OFFSETS; 371 } 372 IMAGE_TABLE = NULL; 373 if ((N = get_argument (argc, argv, "-parallel-images"))) { 374 remove_argument (N, &argc, argv); 375 mode = PARALLEL_IMAGES; 376 if (N >= argc) relphot_usage(); 377 IMAGE_TABLE = strcreate (argv[N]); 378 remove_argument (N, &argc, argv); 379 if (!REGION_FILE) relphot_usage(); 380 } 381 382 PARALLEL_REGIONS_MANUAL = FALSE; 383 if ((N = get_argument (argc, argv, "-parallel-regions"))) { 384 remove_argument (N, &argc, argv); 385 mode = PARALLEL_REGIONS; 386 if (!REGION_FILE) relphot_usage(); 387 if ((N = get_argument (argc, argv, "-parallel-regions-manual"))) { 388 remove_argument (N, &argc, argv); 389 PARALLEL_REGIONS_MANUAL = TRUE; 390 } 391 } 392 393 switch (mode) { 394 case UPDATE_AVERAGES: 395 if (argc != 1) relphot_usage(); 396 break; 397 398 case UPDATE_IMAGES: 399 case PARALLEL_IMAGES: 400 case PARALLEL_REGIONS: 401 PhotcodeList = strcreate (argv[1]); 402 photcodes = ParsePhotcodeList (PhotcodeList, &Nphotcodes, TRUE); // require SEC photcodes 403 remove_argument (1, &argc, argv); 404 break; 405 406 default: 407 fprintf (stderr, "no valid mode selected\n"); 408 relphot_usage(); 409 break; 410 } 411 if (argc != 1) relphot_usage (); 412 413 return mode; 414 } 415 416 int args_client (int argc, char **argv) { 417 418 int N; 419 double trange; 420 421 // by definition, the client is not parallel 422 PARALLEL = FALSE; 423 PARALLEL_MANUAL = FALSE; 424 PARALLEL_SERIAL = FALSE; 425 426 HOST_ID = 0; 427 if ((N = get_argument (argc, argv, "-hostID"))) { 428 remove_argument (N, &argc, argv); 429 HOST_ID = atoi (argv[N]); 430 remove_argument (N, &argc, argv); 431 } 432 if (!HOST_ID) relphot_client_usage(); 433 434 HOSTDIR = NULL; 435 if ((N = get_argument (argc, argv, "-hostdir"))) { 436 remove_argument (N, &argc, argv); 437 HOSTDIR = strcreate (argv[N]); 438 remove_argument (N, &argc, argv); 439 } 440 if (!HOSTDIR) relphot_client_usage(); 441 442 IMAGES = NULL; // used in -update mode 443 BCATALOG = NULL; // used in -load mode 444 MODE = MODE_NONE; 445 if ((N = get_argument (argc, argv, "-load"))) { 446 MODE = MODE_LOAD; 447 remove_argument (N, &argc, argv); 448 BCATALOG = strcreate (argv[N]); 449 remove_argument (N, &argc, argv); 450 } 451 if ((N = get_argument (argc, argv, "-update-catalogs"))) { 452 if (MODE) { 453 fprintf (stderr, "ERROR: cannot mix modes (-load, -update-catalogs, -update-objects)\n"); 454 relphot_client_usage(); 455 } 456 MODE = MODE_UPDATE; 457 remove_argument (N, &argc, argv); 458 IMAGES = strcreate (argv[N]); 459 remove_argument (N, &argc, argv); 460 } 461 if ((N = get_argument (argc, argv, "-update-objects"))) { 462 if (MODE) { 463 fprintf (stderr, "ERROR: cannot mix modes (-load, -update-catalogs, -update-objects)\n"); 464 relphot_client_usage(); 465 } 466 MODE = MODE_UPDATE_OBJECTS; 467 remove_argument (N, &argc, argv); 468 } 469 if (!MODE) relphot_client_usage(); 470 471 strcpy (STATMODE, "WT_MEAN"); 472 if ((N = get_argument (argc, argv, "-statmode"))) { 473 remove_argument (N, &argc, argv); 474 strcpy (STATMODE, argv[N]); 475 remove_argument (N, &argc, argv); 476 } 477 478 BOUNDARY_TREE = NULL; 479 if ((N = get_argument (argc, argv, "-boundary-tree"))) { 480 remove_argument (N, &argc, argv); 481 BOUNDARY_TREE = strcreate(argv[N]); 482 load_tess (BOUNDARY_TREE); 483 remove_argument (N, &argc, argv); 484 } 485 486 /* specify portion of the sky */ 487 UserPatch.Rmin = 0; 488 UserPatch.Rmax = 360; 489 UserPatch.Dmin = -90; 490 UserPatch.Dmax = +90; 491 if ((N = get_argument (argc, argv, "-region"))) { 492 remove_argument (N, &argc, argv); 493 UserPatch.Rmin = atof (argv[N]); 494 remove_argument (N, &argc, argv); 495 UserPatch.Rmax = atof (argv[N]); 496 remove_argument (N, &argc, argv); 497 UserPatch.Dmin = atof (argv[N]); 498 remove_argument (N, &argc, argv); 499 UserPatch.Dmax = atof (argv[N]); 500 remove_argument (N, &argc, argv); 501 } 502 503 SET_MREL_VERSION = 1; 504 if ((N = get_argument (argc, argv, "-set-mrel-version"))) { 505 remove_argument (N, &argc, argv); 506 SET_MREL_VERSION = atof(argv[N]); 507 remove_argument (N, &argc, argv); 508 } 509 510 VERBOSE = VERBOSE2 = FALSE; 511 if ((N = get_argument (argc, argv, "-v"))) { 512 VERBOSE = TRUE; 513 remove_argument (N, &argc, argv); 514 } 515 if ((N = get_argument (argc, argv, "-vv"))) { 516 VERBOSE2 = VERBOSE = TRUE; 517 remove_argument (N, &argc, argv); 518 } 519 520 RESET = FALSE; 521 if ((N = get_argument (argc, argv, "-reset"))) { 522 remove_argument (N, &argc, argv); 523 RESET = TRUE; 524 } 525 526 RESET_ZEROPTS = FALSE; 527 if ((N = get_argument (argc, argv, "-reset-zpts"))) { 528 remove_argument (N, &argc, argv); 529 RESET_ZEROPTS = TRUE; 530 } 531 532 KEEP_UBERCAL = TRUE; 533 if ((N = get_argument (argc, argv, "-reset-ubercal"))) { 534 remove_argument (N, &argc, argv); 535 KEEP_UBERCAL = FALSE; 536 } 7 537 8 538 /* define time */ … … 33 563 } 34 564 35 /* specify portion of the sky */ 36 UserPatch.Rmin = 0; 37 UserPatch.Rmax = 360; 38 UserPatch.Dmin = -90; 39 UserPatch.Dmax = +90; 40 if ((N = get_argument (argc, argv, "-region"))) { 41 remove_argument (N, &argc, argv); 42 UserPatch.Rmin = atof (argv[N]); 43 remove_argument (N, &argc, argv); 44 UserPatch.Rmax = atof (argv[N]); 45 remove_argument (N, &argc, argv); 46 UserPatch.Dmin = atof (argv[N]); 47 remove_argument (N, &argc, argv); 48 UserPatch.Dmax = atof (argv[N]); 49 remove_argument (N, &argc, argv); 50 } 51 52 /* specify region file by name (eg n0000/0000.00) */ 53 UserCatalog = NULL; 54 if ((N = get_argument (argc, argv, "-catalog"))) { 55 remove_argument (N, &argc, argv); 56 UserCatalog = strcreate (argv[N]); 57 remove_argument (N, &argc, argv); 58 } 59 60 USE_BASIC_CHECK = FALSE; 61 if ((N = get_argument (argc, argv, "-basic-image-search"))) { 62 remove_argument (N, &argc, argv); 63 USE_BASIC_CHECK = TRUE; 64 } 65 66 USE_FULL_OVERLAP = TRUE; 67 if ((N = get_argument (argc, argv, "-sloppy-image-overlap"))) { 68 remove_argument (N, &argc, argv); 69 USE_FULL_OVERLAP = FALSE; 70 } 71 72 SET_MREL_VERSION = 1; 73 if ((N = get_argument (argc, argv, "-set-mrel-version"))) { 74 remove_argument (N, &argc, argv); 75 SET_MREL_VERSION = atof(argv[N]); 76 remove_argument (N, &argc, argv); 77 } 78 79 VERBOSE = VERBOSE2 = FALSE; 80 if ((N = get_argument (argc, argv, "-v"))) { 81 VERBOSE = TRUE; 82 remove_argument (N, &argc, argv); 83 } 84 if ((N = get_argument (argc, argv, "-vv"))) { 85 VERBOSE2 = VERBOSE = TRUE; 86 remove_argument (N, &argc, argv); 87 } 88 89 NTHREADS = 0; 90 if ((N = get_argument (argc, argv, "-threads"))) { 91 remove_argument (N, &argc, argv); 92 NTHREADS = atof (argv[N]); 93 remove_argument (N, &argc, argv); 94 } 95 96 // XXX for the moment, make this selection manual. it needs to be automatic 97 // based on the state of the SkyTable 98 HOST_ID = 0; 99 PARALLEL = FALSE; 100 if ((N = get_argument (argc, argv, "-parallel"))) { 101 PARALLEL = TRUE; 102 remove_argument (N, &argc, argv); 103 } 104 // this is a test mode : rather than launching the remote jobs and waiting for completion, 105 // relphot will simply list the remote command and wait for the user to signal completion 106 PARALLEL_MANUAL = FALSE; 107 if ((N = get_argument (argc, argv, "-parallel-manual"))) { 108 PARALLEL = TRUE; // -parallel-manual implies -parallel 109 PARALLEL_MANUAL = TRUE; 110 remove_argument (N, &argc, argv); 111 } 112 // this is a test mode : rather than launching the relphot_client jobs remotely, they are 113 // run in serial via 'system' 114 PARALLEL_SERIAL = FALSE; 115 if ((N = get_argument (argc, argv, "-parallel-serial"))) { 116 if (PARALLEL_MANUAL) { 117 fprintf (stderr, "ERROR: cannot mix -parallel-manual and -parallel-serial\n"); 118 exit (1); 119 } 120 PARALLEL = TRUE; // -parallel-serial implies -parallel 121 PARALLEL_SERIAL = TRUE; 122 remove_argument (N, &argc, argv); 123 } 124 125 PLOTSTUFF = FALSE; 126 if ((N = get_argument (argc, argv, "-plot"))) { 127 PLOTSTUFF = TRUE; 128 remove_argument (N, &argc, argv); 129 } 130 131 PLOTDELAY = 500000; 132 if ((N = get_argument (argc, argv, "-plotdelay"))) { 133 remove_argument (N, &argc, argv); 134 PLOTDELAY = 1e6*atof(argv[N]); 135 PLOTSTUFF = TRUE; // always turn on plotting if i request a plot delay 136 remove_argument (N, &argc, argv); 137 } 138 139 if ((N = get_argument (argc, argv, "-outroot"))) { 140 remove_argument (N, &argc, argv); 141 OUTROOT = strcreate (argv[N]); 142 remove_argument (N, &argc, argv); 143 } else { 144 OUTROOT = strcreate ("relphot"); 145 } 146 147 strcpy (STATMODE, "WT_MEAN"); 148 if ((N = get_argument (argc, argv, "-statmode"))) { 149 remove_argument (N, &argc, argv); 150 strcpy (STATMODE, argv[N]); 151 remove_argument (N, &argc, argv); 152 } 153 154 NLOOP = 8; 155 if ((N = get_argument (argc, argv, "-n"))) { 156 remove_argument (N, &argc, argv); 157 NLOOP = atof (argv[N]); 158 remove_argument (N, &argc, argv); 159 } 160 if ((N = get_argument (argc, argv, "-nloop"))) { 161 remove_argument (N, &argc, argv); 162 NLOOP = atof (argv[N]); 163 remove_argument (N, &argc, argv); 164 } 165 166 NGRID = 8; 167 if ((N = get_argument (argc, argv, "-ngrid"))) { 168 remove_argument (N, &argc, argv); 169 NGRID = atof (argv[N]); 170 remove_argument (N, &argc, argv); 171 } 172 173 RESET = FALSE; 174 if ((N = get_argument (argc, argv, "-reset"))) { 175 remove_argument (N, &argc, argv); 176 RESET = TRUE; 177 } 178 179 RESET_ZEROPTS = FALSE; 180 if ((N = get_argument (argc, argv, "-reset-zpts"))) { 181 remove_argument (N, &argc, argv); 182 RESET_ZEROPTS = TRUE; 183 } 565 566 MIN_ERROR = 0.001; 567 if ((N = get_argument (argc, argv, "-minerror"))) { 568 remove_argument (N, &argc, argv); 569 MIN_ERROR = atof (argv[N]); 570 remove_argument (N, &argc, argv); 571 /* require MIN_ERROR > 0 */ 572 } 184 573 185 574 UPDATE = FALSE; … … 196 585 } 197 586 198 SAVE_IMAGE_UPDATES = TRUE; 199 if ((N = get_argument (argc, argv, "-skip-image-updates"))) { 200 remove_argument (N, &argc, argv); 201 SAVE_IMAGE_UPDATES = FALSE; 587 AreaSelect = FALSE; 588 if ((N = get_argument (argc, argv, "-area"))) { 589 remove_argument (N, &argc, argv); 590 AreaXmin = atof (argv[N]); 591 remove_argument (N, &argc, argv); 592 AreaXmax = atof (argv[N]); 593 remove_argument (N, &argc, argv); 594 AreaYmin = atof (argv[N]); 595 remove_argument (N, &argc, argv); 596 AreaYmax = atof (argv[N]); 597 remove_argument (N, &argc, argv); 598 AreaSelect = TRUE; 599 } 600 601 SyntheticPhotometry = FALSE; 602 if ((N = get_argument (argc, argv, "-synthphot"))) { 603 remove_argument (N, &argc, argv); 604 SyntheticPhotometry = FALSE; 605 init_synthetic_mags(); 606 } 607 608 ImagSelect = FALSE; 609 if ((N = get_argument (argc, argv, "-instmag"))) { 610 remove_argument (N, &argc, argv); 611 ImagMin = atof (argv[N]); 612 remove_argument (N, &argc, argv); 613 ImagMax = atof (argv[N]); 614 remove_argument (N, &argc, argv); 615 ImagSelect = TRUE; 616 } 617 618 DophotSelect = FALSE; 619 if ((N = get_argument (argc, argv, "-dophot"))) { 620 remove_argument (N, &argc, argv); 621 DophotValue = atof (argv[N]); 622 remove_argument (N, &argc, argv); 623 DophotSelect = TRUE; 202 624 } 203 625 … … 210 632 } 211 633 212 CLOUD_TOLERANCE = 0.02; 213 if ((N = get_argument (argc, argv, "-cloud-limit"))) { 214 remove_argument (N, &argc, argv); 215 CLOUD_TOLERANCE = atof(argv[N]); 216 remove_argument (N, &argc, argv); 217 } 218 219 BOUNDARY_TREE = NULL; 220 if ((N = get_argument (argc, argv, "-boundary-tree"))) { 221 remove_argument (N, &argc, argv); 222 BOUNDARY_TREE = strcreate(argv[N]); 223 load_tree (BOUNDARY_TREE); 224 remove_argument (N, &argc, argv); 225 } 226 227 SHOW_PARAMS = FALSE; 228 if ((N = get_argument (argc, argv, "-params"))) { 229 remove_argument (N, &argc, argv); 230 SHOW_PARAMS = TRUE; 231 } 232 233 PlotMmin = 10.0; PlotMmax = 20.0; PlotdMmin = -1.0; PlotdMmax = 1.0; 234 if ((N = get_argument (argc, argv, "-plrange"))) { 235 remove_argument (N, &argc, argv); 236 PlotMmin = atof (argv[N]); 237 remove_argument (N, &argc, argv); 238 PlotMmax = atof (argv[N]); 239 remove_argument (N, &argc, argv); 240 PlotdMmin = atof (argv[N]); 241 remove_argument (N, &argc, argv); 242 PlotdMmax = atof (argv[N]); 243 remove_argument (N, &argc, argv); 244 } 245 246 /* XXX this argument used to do two things: specify the camera name and tell the analysis to 247 calculate a common zero point for a single mosaic. I've moved the MOSAICNAME concept into the 248 config system, but need to use this argument to specify that the mosaic zeropoints should be 249 calculated. */ 250 MOSAIC_ZEROPT = FALSE; 251 if ((N = get_argument (argc, argv, "-mosaic"))) { 252 remove_argument (N, &argc, argv); 253 MOSAIC_ZEROPT = TRUE; 254 if (!strcasecmp (MOSAICNAME, "none")) { 255 fprintf (stderr, "mosaic astrometry selected by MOSAICNAME not defined\n"); 256 exit (2); 257 } 258 } 259 260 FREEZE_IMAGES = FALSE; 261 if ((N = get_argument (argc, argv, "-imfreeze"))) { 262 remove_argument (N, &argc, argv); 263 FREEZE_IMAGES = TRUE; 264 } 265 266 FREEZE_MOSAICS = FALSE; 267 if ((N = get_argument (argc, argv, "-mosfreeze"))) { 268 remove_argument (N, &argc, argv); 269 FREEZE_MOSAICS = TRUE; 270 } 271 272 USE_GRID = FALSE; 273 if ((N = get_argument (argc, argv, "-grid"))) { 274 remove_argument (N, &argc, argv); 275 USE_GRID = TRUE; 276 } 277 278 KEEP_UBERCAL = TRUE; 279 if ((N = get_argument (argc, argv, "-reset-ubercal"))) { 280 remove_argument (N, &argc, argv); 281 KEEP_UBERCAL = FALSE; 282 } 283 284 MIN_ERROR = 0.001; 285 if ((N = get_argument (argc, argv, "-minerror"))) { 286 remove_argument (N, &argc, argv); 287 MIN_ERROR = atof (argv[N]); 288 remove_argument (N, &argc, argv); 289 /* require MIN_ERROR > 0 */ 290 } 291 292 AreaSelect = FALSE; 293 if ((N = get_argument (argc, argv, "-area"))) { 294 remove_argument (N, &argc, argv); 295 AreaXmin = atof (argv[N]); 296 remove_argument (N, &argc, argv); 297 AreaXmax = atof (argv[N]); 298 remove_argument (N, &argc, argv); 299 AreaYmin = atof (argv[N]); 300 remove_argument (N, &argc, argv); 301 AreaYmax = atof (argv[N]); 302 remove_argument (N, &argc, argv); 303 AreaSelect = TRUE; 304 } 305 306 ImagSelect = FALSE; 307 if ((N = get_argument (argc, argv, "-instmag"))) { 308 remove_argument (N, &argc, argv); 309 ImagMin = atof (argv[N]); 310 remove_argument (N, &argc, argv); 311 ImagMax = atof (argv[N]); 312 remove_argument (N, &argc, argv); 313 ImagSelect = TRUE; 314 } 315 316 DophotSelect = FALSE; 317 if ((N = get_argument (argc, argv, "-dophot"))) { 318 remove_argument (N, &argc, argv); 319 DophotValue = atof (argv[N]); 320 remove_argument (N, &argc, argv); 321 DophotSelect = TRUE; 322 } 323 324 SyntheticPhotometry = FALSE; 325 if ((N = get_argument (argc, argv, "-synthphot"))) { 326 remove_argument (N, &argc, argv); 327 SyntheticPhotometry = TRUE; 328 init_synthetic_mags(); 329 } 330 331 refPhotcode = NULL; 332 if ((N = get_argument (argc, argv, "-refcode"))) { 333 remove_argument (N, &argc, argv); 334 refPhotcode = GetPhotcodebyName (argv[N]); 335 if (!refPhotcode) { 336 fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", argv[N]); 337 exit (1); 338 } 339 remove_argument (N, &argc, argv); 340 } 341 342 UpdateAverages = FALSE; 343 if ((N = get_argument (argc, argv, "-averages"))) { 344 remove_argument (N, &argc, argv); 345 UpdateAverages = TRUE; 346 } 347 348 ApplyOffsets = FALSE; 349 if ((N = get_argument (argc, argv, "-apply-offsets"))) { 350 remove_argument (N, &argc, argv); 351 ApplyOffsets = TRUE; 352 } 353 354 if (UpdateAverages && (argc == 1)) return TRUE; 355 if (argc != 2) relphot_usage (); 634 if ((MODE == MODE_UPDATE_OBJECTS) && (argc == 1)) return TRUE; 635 if (argc != 2) relphot_client_usage (); 356 636 357 637 return TRUE; 358 638 } 359 639 360 int args_client (int argc, char **argv) {361 362 int N;363 double trange;364 365 // by definition, the client is not parallel366 PARALLEL = FALSE;367 PARALLEL_MANUAL = FALSE;368 PARALLEL_SERIAL = FALSE;369 370 HOST_ID = 0;371 if ((N = get_argument (argc, argv, "-hostID"))) {372 remove_argument (N, &argc, argv);373 HOST_ID = atoi (argv[N]);374 remove_argument (N, &argc, argv);375 }376 if (!HOST_ID) relphot_client_usage();377 378 HOSTDIR = NULL;379 if ((N = get_argument (argc, argv, "-hostdir"))) {380 remove_argument (N, &argc, argv);381 HOSTDIR = strcreate (argv[N]);382 remove_argument (N, &argc, argv);383 }384 if (!HOSTDIR) relphot_client_usage();385 386 IMAGES = NULL; // used in -update mode387 BCATALOG = NULL; // used in -load mode388 MODE = MODE_NONE;389 if ((N = get_argument (argc, argv, "-load"))) {390 MODE = MODE_LOAD;391 remove_argument (N, &argc, argv);392 BCATALOG = strcreate (argv[N]);393 remove_argument (N, &argc, argv);394 }395 if ((N = get_argument (argc, argv, "-update-catalogs"))) {396 if (MODE) {397 fprintf (stderr, "ERROR: cannot mix modes (-load, -update-catalogs, -update-objects)\n");398 relphot_client_usage();399 }400 MODE = MODE_UPDATE;401 remove_argument (N, &argc, argv);402 IMAGES = strcreate (argv[N]);403 remove_argument (N, &argc, argv);404 }405 if ((N = get_argument (argc, argv, "-update-objects"))) {406 if (MODE) {407 fprintf (stderr, "ERROR: cannot mix modes (-load, -update-catalogs, -update-objects)\n");408 relphot_client_usage();409 }410 MODE = MODE_UPDATE_OBJECTS;411 remove_argument (N, &argc, argv);412 }413 if (!MODE) relphot_client_usage();414 415 strcpy (STATMODE, "WT_MEAN");416 if ((N = get_argument (argc, argv, "-statmode"))) {417 remove_argument (N, &argc, argv);418 strcpy (STATMODE, argv[N]);419 remove_argument (N, &argc, argv);420 }421 422 BOUNDARY_TREE = NULL;423 if ((N = get_argument (argc, argv, "-boundary-tree"))) {424 remove_argument (N, &argc, argv);425 BOUNDARY_TREE = strcreate(argv[N]);426 load_tree (BOUNDARY_TREE);427 remove_argument (N, &argc, argv);428 }429 430 /* specify portion of the sky */431 UserPatch.Rmin = 0;432 UserPatch.Rmax = 360;433 UserPatch.Dmin = -90;434 UserPatch.Dmax = +90;435 if ((N = get_argument (argc, argv, "-region"))) {436 remove_argument (N, &argc, argv);437 UserPatch.Rmin = atof (argv[N]);438 remove_argument (N, &argc, argv);439 UserPatch.Rmax = atof (argv[N]);440 remove_argument (N, &argc, argv);441 UserPatch.Dmin = atof (argv[N]);442 remove_argument (N, &argc, argv);443 UserPatch.Dmax = atof (argv[N]);444 remove_argument (N, &argc, argv);445 }446 447 SET_MREL_VERSION = 1;448 if ((N = get_argument (argc, argv, "-set-mrel-version"))) {449 remove_argument (N, &argc, argv);450 SET_MREL_VERSION = atof(argv[N]);451 remove_argument (N, &argc, argv);452 }453 454 VERBOSE = VERBOSE2 = FALSE;455 if ((N = get_argument (argc, argv, "-v"))) {456 VERBOSE = TRUE;457 remove_argument (N, &argc, argv);458 }459 if ((N = get_argument (argc, argv, "-vv"))) {460 VERBOSE2 = VERBOSE = TRUE;461 remove_argument (N, &argc, argv);462 }463 464 RESET = FALSE;465 if ((N = get_argument (argc, argv, "-reset"))) {466 remove_argument (N, &argc, argv);467 RESET = TRUE;468 }469 470 RESET_ZEROPTS = FALSE;471 if ((N = get_argument (argc, argv, "-reset-zpts"))) {472 remove_argument (N, &argc, argv);473 RESET_ZEROPTS = TRUE;474 }475 476 KEEP_UBERCAL = TRUE;477 if ((N = get_argument (argc, argv, "-reset-ubercal"))) {478 remove_argument (N, &argc, argv);479 KEEP_UBERCAL = FALSE;480 }481 482 /* define time */483 TimeSelect = FALSE;484 if ((N = get_argument (argc, argv, "-time"))) {485 remove_argument (N, &argc, argv);486 if (!ohana_str_to_time (argv[N], &TSTART)) {487 fprintf (stderr, "ERROR: syntax error\n");488 return (FALSE);489 }490 remove_argument (N, &argc, argv);491 if (!ohana_str_to_dtime (argv[N], &trange)) {492 if (!ohana_str_to_time (argv[N], &TSTOP)) {493 fprintf (stderr, "ERROR: syntax error\n");494 return (FALSE);495 }496 } else {497 if (trange < 0) {498 trange = fabs (trange);499 TSTOP = TSTART;500 TSTART -= trange;501 } else {502 TSTOP = TSTART + trange;503 }504 }505 remove_argument (N, &argc, argv);506 TimeSelect = TRUE;507 }508 509 510 MIN_ERROR = 0.001;511 if ((N = get_argument (argc, argv, "-minerror"))) {512 remove_argument (N, &argc, argv);513 MIN_ERROR = atof (argv[N]);514 remove_argument (N, &argc, argv);515 /* require MIN_ERROR > 0 */516 }517 518 UPDATE = FALSE;519 if ((N = get_argument (argc, argv, "-update"))) {520 remove_argument (N, &argc, argv);521 UPDATE = TRUE;522 }523 524 UPDATE_CATFORMAT = NULL;525 if ((N = get_argument (argc, argv, "-update-catformat"))) {526 remove_argument (N, &argc, argv);527 UPDATE_CATFORMAT = strcreate (argv[N]);528 remove_argument (N, &argc, argv);529 }530 531 AreaSelect = FALSE;532 if ((N = get_argument (argc, argv, "-area"))) {533 remove_argument (N, &argc, argv);534 AreaXmin = atof (argv[N]);535 remove_argument (N, &argc, argv);536 AreaXmax = atof (argv[N]);537 remove_argument (N, &argc, argv);538 AreaYmin = atof (argv[N]);539 remove_argument (N, &argc, argv);540 AreaYmax = atof (argv[N]);541 remove_argument (N, &argc, argv);542 AreaSelect = TRUE;543 }544 545 SyntheticPhotometry = FALSE;546 if ((N = get_argument (argc, argv, "-synthphot"))) {547 remove_argument (N, &argc, argv);548 SyntheticPhotometry = FALSE;549 init_synthetic_mags();550 }551 552 ImagSelect = FALSE;553 if ((N = get_argument (argc, argv, "-instmag"))) {554 remove_argument (N, &argc, argv);555 ImagMin = atof (argv[N]);556 remove_argument (N, &argc, argv);557 ImagMax = atof (argv[N]);558 remove_argument (N, &argc, argv);559 ImagSelect = TRUE;560 }561 562 DophotSelect = FALSE;563 if ((N = get_argument (argc, argv, "-dophot"))) {564 remove_argument (N, &argc, argv);565 DophotValue = atof (argv[N]);566 remove_argument (N, &argc, argv);567 DophotSelect = TRUE;568 }569 570 MaxDensityUse = FALSE;571 if ((N = get_argument (argc, argv, "-max-density"))) {572 remove_argument (N, &argc, argv);573 MaxDensityValue = atof(argv[N]);574 remove_argument (N, &argc, argv);575 MaxDensityUse = TRUE;576 }577 578 if ((MODE == MODE_UPDATE_OBJECTS) && (argc == 1)) return TRUE;579 if (argc != 2) relphot_client_usage ();580 581 return TRUE;582 }583 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/client_logger.c
r33963 r36680 5 5 6 6 static FILE *logfile = NULL; 7 int client_logger_init ( ) {7 int client_logger_init (char *dirname) { 8 8 9 9 char filename[DVO_MAX_PATH]; 10 10 11 snprintf (filename, DVO_MAX_PATH, "%s/log.rlpc.XXXXXX", HOSTDIR);11 snprintf (filename, DVO_MAX_PATH, "%s/log.rlpc.XXXXXX", dirname); 12 12 13 13 int fd = mkstemp (filename); 14 14 if (fd == -1) { 15 fprintf (stderr, "failed to open client logger , exiting\n");15 fprintf (stderr, "failed to open client logger %s, exiting\n", filename); 16 16 exit (50); 17 17 } … … 32 32 vfprintf (logfile, format, argp); 33 33 va_end (argp); 34 35 fflush (logfile); 34 36 return TRUE; 35 37 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/help.c
r33651 r36680 2 2 3 3 void relphot_usage (void) { 4 fprintf (stderr, "ERROR: USAGE: relphot (photcodes) -region RA RA DEC DEC\n"); 5 fprintf (stderr, " or: relphot (photcodes) -catalog (name)\n"); 6 fprintf (stderr, " or: relphot -averages -region RA RA DEC DEC\n"); 4 fprintf (stderr, "ERROR: USAGE: relphot (photcodes) -images\n"); 5 fprintf (stderr, " or: relphot -averages\n"); 6 fprintf (stderr, " or: relphot -apply-offsets\n"); 7 fprintf (stderr, " or: relphot (photcodes) -parallel-regions -region-hosts (RegionFile)\n"); 8 fprintf (stderr, " or: relphot (photcodes) -parallel-images (ImageTable) -region-hosts (RegionFile)\n\n"); 9 fprintf (stderr, " regions: -region RA RA DEC DEC)\n"); 10 fprintf (stderr, " or: -catalog (name)\n"); 7 11 fprintf (stderr, " use -h for more usage information\n"); 8 12 exit (2); … … 18 22 19 23 show_help: 20 fprintf (stderr, "ERROR: USAGE: relphot (photcode) -region RA RA DEC DEC\n"); 21 fprintf (stderr, " or: relphot (photcode) -catalog (name)\n"); 22 fprintf (stderr, " or: relphot -averages -region RA RA DEC DEC\n"); 24 fprintf (stderr, "ERROR: USAGE: relphot (photcodes) -images\n"); 25 fprintf (stderr, " or: relphot -averages\n"); 26 fprintf (stderr, " or: relphot -apply-offsets\n"); 27 fprintf (stderr, " or: relphot (photcodes) -parallel-regions -region-hosts (RegionFile)\n"); 28 fprintf (stderr, " or: relphot (photcodes) -parallel-images (ImageTable) -region-hosts (RegionFile)\n\n"); 29 fprintf (stderr, " regions: -region RA RA DEC DEC)\n"); 30 fprintf (stderr, " or: -catalog (name)\n"); 23 31 fprintf (stderr, " options: \n"); 24 32 fprintf (stderr, " -time (start) (stop)\n"); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/initialize.c
r34429 r36680 1 1 # include "relphot.h" 2 2 3 voidinitialize (int argc, char **argv) {3 RelphotMode initialize (int argc, char **argv) { 4 4 5 5 relphot_help (argc, argv); 6 6 ConfigInit (&argc, argv); 7 args (argc, argv); 7 RelphotMode mode = args (argc, argv); 8 if (!mode) exit (2); 8 9 9 if (!UpdateAverages) { 10 // load the list of photcodes into the globals (photcodes, Nphotcodes) 11 // only a single remaining argument in this mode (the list of photcodes, eg g,r,i) 12 PhotcodeList = strcreate (argv[1]); 13 photcodes = ParsePhotcodeList (PhotcodeList, &Nphotcodes, TRUE); // require SEC photcodes 14 } else { 10 // UPDATE_AVERAGES always operates on all photcodes? 11 if (mode == UPDATE_AVERAGES) { 15 12 char tmpline1[256]; 16 13 int Ns; … … 67 64 for (B = 0; A == time(NULL); B++); 68 65 srand48(B); 66 67 return mode; 69 68 } 70 69 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/load_catalogs.c
r35416 r36680 89 89 90 90 fprintf (stderr, "using "OFF_T_FMT" of "OFF_T_FMT" stars ("OFF_T_FMT" of "OFF_T_FMT" measurements)\n", Nstar, Nstar_total, Nmeas, Nmeas_total); 91 if (!hostID && (Nstar < 1)) Shutdown ("%s", "ERROR: no stars match the minimum requirements; exiting \n");91 if (!hostID && !REGION_HOST_ID && (Nstar < 1)) Shutdown ("%s", "ERROR: no stars match the minimum requirements; exiting \n"); 92 92 // in regular relphot, we shutdown here; in relphot_client, we generate and return an empty table (for consistency) 93 94 93 95 94 // XXX consider only returning the populated catalogs … … 107 106 # define DEBUG 1 108 107 Catalog *load_catalogs_parallel (SkyList *sky, int *Ncatalog) { 108 109 char uniquer[12]; 110 int TIME = time(NULL); 111 int PID = getpid(); 112 snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000); 109 113 110 114 int Nsecfilt = GetPhotcodeNsecfilt (); // set the desired number in case we need to create the catalog … … 128 132 129 133 ALLOCATE (table->hosts[i].results, char, 1024); 130 snprintf (table->hosts[i].results, 1024, "%s/relphot.catalog. subset.dat", table->hosts[i].pathname);134 snprintf (table->hosts[i].results, 1024, "%s/relphot.catalog.%s.dat", table->hosts[i].pathname, uniquer); 131 135 132 136 // options / arguments that can affect relphot_client -load: -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/reload_catalogs.c
r35806 r36680 156 156 // load the list of hosts 157 157 HostTable *table = HostTableLoad (CATDIR, sky->hosts); 158 if (!table) { 159 fprintf (stderr, "ERROR: problem with parallel host table\n"); 160 exit (2); 161 } 158 162 159 163 if (BOUNDARY_TREE) { -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/relphot.c
r35416 r36680 3 3 int main (int argc, char **argv) { 4 4 5 /* get configuration info, args */ 6 initialize (argc, argv); 5 // get configuration info, args 6 RelphotMode mode = initialize (argc, argv); 7 if (!mode) exit (2); 7 8 8 /* the object analysis is a separate process iterating over catalogs */ 9 if (UpdateAverages) { 10 relphot_objects (0, NULL); 11 exit (0); 9 switch (mode) { 10 case UPDATE_IMAGES: 11 relphot_images (); 12 exit (0); 13 14 case UPDATE_AVERAGES: 15 // take the current set of detections and set the mean magnitudes 16 relphot_objects (0, NULL); 17 exit (0); 18 19 case PARALLEL_REGIONS: 20 // run image updates in parallel across multiple remote machines 21 relphot_parallel_regions (); 22 exit (0); 23 24 case PARALLEL_IMAGES: 25 // operation on the remote machines in the PARALLEL_REGION mode 26 relphot_parallel_images (); 27 exit (0); 28 29 case APPLY_OFFSETS: 30 // re-run this step from a previous attempt (assumes an existing Images.subset.dat file) 31 if (!PARALLEL) { 32 fprintf (stderr, "-apply-offsets only makes sense in an parallel context\n"); 33 exit (2); 34 } 35 reload_catalogs (NULL, NULL, 0, NULL); 36 exit (0); 37 38 default: 39 fprintf (stderr, "ERROR: no valid relphot mode chosen\n"); 40 exit (2); 12 41 } 13 14 if (ApplyOffsets) { 15 // re-run this step from a previous attempt (assumes an existing Images.subset.dat file) 16 if (!PARALLEL) { 17 fprintf (stderr, "-apply-offsets only makes sense in an parallel context\n"); 18 exit (2); 19 } 20 reload_catalogs (NULL, NULL, 0, NULL); 21 exit (0); 22 } 23 24 relphot_images (); 25 26 exit (0); 42 fprintf (stderr, "IMPOSSIBLE: skipped out of switch?\n"); 43 exit (1); 27 44 } 28 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/relphot_client.c
r33963 r36680 19 19 // get configuration info, args, lockfile (set CATDIR, HOST_ID, HOSTDIR, etc) 20 20 initialize_client (argc, argv); 21 client_logger_init ( );21 client_logger_init (HOSTDIR); 22 22 23 23 // load the current sky table (layout of all SkyRegions) -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/relphot_images.c
r35806 r36680 244 244 if (!UPDATE) exit (0); 245 245 246 /* load catalog data from region files, update Mrel include all data */ 246 /* Load catalog data from region files, update Mrel include all data. In a parallel 247 context, this function writes the image parameters as a subset table for the remote 248 clients */ 247 249 reload_catalogs (skylist, flatcorr, 0, NULL); 248 250 MARKTIME("-- updated all catalogs: %f sec\n", dtime); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/select_images.c
r35806 r36680 40 40 tcoords.pc1_1 = tcoords.pc2_2 = 1.0; 41 41 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 42 strcpy (tcoords.ctype, " RA---TAN");42 strcpy (tcoords.ctype, "DEC--TAN"); 43 43 44 44 double RminSkyRegion = region[0].Rmin; … … 412 412 tcoords.Npolyterms = 0; 413 413 memset (tcoords.polyterms, 0, 14*sizeof(float)); 414 strcpy (tcoords.ctype, " RA---TAN");414 strcpy (tcoords.ctype, "DEC--TAN"); 415 415 416 416 /* compare with each region file */ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/relphot/src/setMrelCatalog.c
r35759 r36680 34 34 off_t j; 35 35 36 liststats_setmode (&results-> stats, STATMODE);36 liststats_setmode (&results->psfstats, STATMODE); 37 37 liststats_setmode (&results->apstats, STATMODE); 38 38 liststats_setmode (&results->kronstats, STATMODE); … … 67 67 68 68 off_t k; 69 int N;70 69 float Msys = 0, Mcal= 0, Mmos = 0, Mgrid = 0; 71 70 72 double *list = results->list; 73 double *dlist = results->dlist; 74 double *wlist = results->wlist; 75 double *aplist = results->aplist; 76 double *kronlist = results->kronlist; 71 // we are measuring means for 3 types of mags: psf, ap, kron. I am using the psf mag 72 // error for the ap mags, but krons have their own errors. it is an open question if I 73 // should be doing weighted or unweighted fits (this is a user option) 74 double *Mpsflist = results->Mpsflist; 75 double *dpsflist = results->dpsflist; 76 double *wpsflist = results->wpsflist; 77 78 double *Maplist = results->Maplist; 79 double *daplist = results->daplist; 80 double *waplist = results->waplist; 81 82 double *Mkronlist = results->Mkronlist; 77 83 double *dkronlist = results->dkronlist; 78 79 StatType *stats = &results->stats; 80 StatType *apstats = &results->apstats; 84 double *wkronlist = results->wkronlist; 85 86 StatType *psfstats = &results->psfstats; 87 StatType *apstats = &results->apstats; 81 88 StatType *kronstats = &results->kronstats; 82 89 … … 125 132 off_t meas = measureOffset; 126 133 127 N = 0; 134 int Nap = 0; 135 int Npsf = 0; 136 int Nkron = 0; 128 137 for (k = 0; k < averageT[0].Nmeasure; k++, meas++) { 129 138 … … 135 144 136 145 // are we a PS1 exposure photcode? 137 if ((measure [k].photcode >= 10000) && (measure[k].photcode <= 10500)) {146 if ((measureT[k].photcode >= 10000) && (measureT[k].photcode <= 10500)) { 138 147 NexpPS1 ++; 139 148 } … … 164 173 int myUbercalDist = getUbercalDist(meas, cat); 165 174 minUbercalDist = MIN(minUbercalDist, myUbercalDist); 175 176 int isUbercal = (measureT[k].dbFlags & ID_MEAS_PHOTOM_UBERCAL); 177 float dMpsf = MAX (hypot(measureT[k].dM, code->photomErrSys), MIN_ERROR); 178 179 if (isUbercal) haveUbercal = TRUE; // haveUbercal is set per secfilt, isUbercal is per measure 166 180 167 181 if (isSetMrelFinal) { … … 231 245 if (measureT[k].M < MaxMagForceSynth) { 232 246 forceSynth = TRUE; 233 forceSynthEntry = N ;247 forceSynthEntry = Npsf; 234 248 } else { 235 249 if (pass < 4) { … … 240 254 } 241 255 242 // Map (aplist) and Mkron (kronlist,dkronlist) are used to calculate mean mags per filter 243 float Map = PhotAper (&measure[k]); 244 aplist[N] = Map - Mcal - Mmos - Mgrid; 245 246 float Mkron = PhotKron (&measure[k]); 247 kronlist[N] = Mkron - Mcal - Mmos - Mgrid; 248 dkronlist[N] = measure[k].dMkron; 249 } 256 // Map (Maplist) and Mkron (Mkronlist,dkronlist) are used to calculate mean mags per filter 257 float Map = PhotAperCat (&measure[k]); 258 if (!isnan(Map)) { 259 Maplist[Nap] = Map - Mcal - Mmos - Mgrid; 260 daplist[Nap] = dMpsf; 261 waplist[Nap] = isUbercal ? 10.0 : 1.0; 262 Nap ++; 263 } 264 265 float Mkron = PhotKronCat (&measure[k]); 266 if (!isnan(Mkron)) { 267 Mkronlist[Nkron] = Mkron - Mcal - Mmos - Mgrid; 268 dkronlist[Nkron] = measure[k].dMkron; 269 wkronlist[Nkron] = isUbercal ? 10.0 : 1.0; 270 Nkron ++; 271 } 272 } // if (isSetMrelFinal) 250 273 251 274 // dlist gives the error per measurement, wlist gives the weight … … 255 278 // 3) UBERCAL measurements can have their weight increased by a big factor to help tie down the averages 256 279 // 4) some reference photcode of some kind can be specified as fixed and have a high weight 257 dlist[N] = MAX (hypot(measureT[k].dM, code->photomErrSys), MIN_ERROR); 258 wlist[N] = 1.0; 259 list[N] = Msys - Mcal - Mmos - Mgrid; 260 261 // up-weight the ubercal values (or convergence can take a long time...) 262 if (measureT[k].dbFlags & ID_MEAS_PHOTOM_UBERCAL) { 263 haveUbercal = TRUE; 264 wlist[N] = 10.0; 265 } 280 Mpsflist[Npsf] = Msys - Mcal - Mmos - Mgrid; 281 dpsflist[Npsf] = dMpsf; 282 wpsflist[Npsf] = isUbercal ? 10.0 : 1.0; 283 284 // NOTE: 285 // Msys is measure[i].M + zp corrections 286 // Mcal is image[j].Mcal 287 // Mmos and Mgrid are offsets for mosaic and grid 266 288 267 289 // tie down reference photometry if the -refcode (code) option is selected 268 290 // eg, -refcode g_SDSS 269 291 // this probably makes no sense in the context of multifilter analysis 292 // XXX probably need to use the photocde table to assign reference mag weights. 270 293 if (refPhotcode) { 271 294 if (code->code == refPhotcode->code) { 272 w list[N] = 100.0;273 } 274 } 275 N ++;295 wpsflist[Npsf] = 100.0; 296 } 297 } 298 Npsf ++; 276 299 } 277 300 … … 288 311 289 312 // when performing the grid analysis, STAR_TOOFEW should be set to 1; 290 if (N < Nminmeas) { /* too few measurements */291 // fprintf (f, "%10.6f %10.6f %d %d %d\n", averageT[0].R, averageT[0].D, measureT[0].imageID, N , STAR_TOOFEW);313 if (Npsf < Nminmeas) { /* too few measurements */ 314 // fprintf (f, "%10.6f %10.6f %d %d %d\n", averageT[0].R, averageT[0].D, measureT[0].imageID, Npsf, STAR_TOOFEW); 292 315 secfilt[Nsec].flags |= ID_STAR_FEW; 293 316 if (Ncode == 0) { … … 303 326 if (forceSynth) { 304 327 // use the single SYNTH value instead of the other mags here 305 myAssert ((forceSynthEntry < N ) && (forceSynthEntry >= 0), "programming error");306 list[0] =list[forceSynthEntry];307 d list[0] = dlist[forceSynthEntry];308 w list[0] = wlist[forceSynthEntry];309 N = 1;310 } 311 liststats ( list, dlist, wlist, N,stats);312 313 secfilt[Nsec].M = stats->mean;314 secfilt[Nsec].dM = stats->error;315 secfilt[Nsec].Xm = ( stats->Nmeas > 1) ? 100.0*log10(stats->chisq + 1e-4) : NAN_S_SHORT;328 myAssert ((forceSynthEntry < Npsf) && (forceSynthEntry >= 0), "programming error"); 329 Mpsflist[0] = Mpsflist[forceSynthEntry]; 330 dpsflist[0] = dpsflist[forceSynthEntry]; 331 wpsflist[0] = wpsflist[forceSynthEntry]; 332 Npsf = 1; 333 } 334 liststats (Mpsflist, dpsflist, wpsflist, Npsf, psfstats); 335 336 secfilt[Nsec].M = psfstats->mean; 337 secfilt[Nsec].dM = psfstats->error; 338 secfilt[Nsec].Xm = (psfstats->Nmeas > 1) ? 100.0*log10(psfstats->chisq + 1e-4) : NAN_S_SHORT; 316 339 317 340 // when running -averages, we have no information about the images, so we cannot set this … … 323 346 found[Nsec] = TRUE; 324 347 325 secfilt[Nsec].Mstdev = 1000.0* stats->sigma; // Mstdev is in millimags (not enough space for more precision)348 secfilt[Nsec].Mstdev = 1000.0*psfstats->sigma; // Mstdev is in millimags (not enough space for more precision) 326 349 // secfilt[Nsec].Ncode = Ncode; 327 secfilt[Nsec].Nused = stats->Nmeas;328 329 secfilt[Nsec].M_80 = 1000 * stats->Upper80;330 secfilt[Nsec].M_20 = 1000 * stats->Lower20;350 secfilt[Nsec].Nused = psfstats->Nmeas; 351 352 secfilt[Nsec].M_80 = 1000 * psfstats->Upper80; 353 secfilt[Nsec].M_20 = 1000 * psfstats->Lower20; 331 354 332 355 // NOTE : use the modified weight for apmags as well as psf mags 333 liststats ( aplist, dlist, wlist, N, apstats);334 secfilt[Nsec].Map = apstats->mean;335 336 liststats ( kronlist, dkronlist, wlist, N, kronstats);337 secfilt[Nsec].Mkron = kronstats->mean;338 secfilt[Nsec].dMkron = kronstats->error;356 liststats (Maplist, daplist, waplist, Nap, apstats); 357 secfilt[Nsec].Map = Nap > 0 ? apstats->mean : NAN; 358 359 liststats (Mkronlist, dkronlist, wkronlist, Nkron, kronstats); 360 secfilt[Nsec].Mkron = Nkron > 0 ? kronstats->mean : NAN; 361 secfilt[Nsec].dMkron = Nkron > 0 ? kronstats->error : NAN; 339 362 340 363 // NOTE: for 2MASS measurements, Next should be 1, as should N 341 if ((Next > 0) && (Next > 0.5*N )) {364 if ((Next > 0) && (Next > 0.5*Npsf)) { 342 365 secfilt[Nsec].flags |= ID_SECF_OBJ_EXT; 343 366 } … … 405 428 float Msys = 0, Mcal= 0, Mmos = 0, Mgrid = 0; 406 429 407 // set the name of the primary skycell (this is used in a strcmp to match the skycells in stack detections)408 // XXX drop BoundaryTreePrimaryCell(primaryCell, average[0].R, average[0].D);430 // set the primary projection cell and skycell for this coordinate 431 int tessID = -1; 409 432 int projectID = -1; 410 433 int skycellID = -1; 411 BoundaryTreePrimaryCellIDs(&projectID, &skycellID, average[0].R, average[0].D);434 get_tess_ids(&tessID, &projectID, &skycellID, average[0].R, average[0].D); 412 435 413 436 int NstackGood = 0; … … 477 500 // which stack image should we use for the mean value? 478 501 // if we request the primary (USE_TREE_FOR_PRIMARY), then find the min distances for data from the primary cell 479 if (MatchImageSkycellID (meas, cat, projectID, skycellID)) {502 if (MatchImageSkycellID (meas, cat, tessID, projectID, skycellID)) { 480 503 float stackPrimaryOffset = getCenterOffset (meas, cat, &measure[k], &stackImageID); 481 504 if (stackPrimaryOffset < stackPrimaryOffsetMin) { -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/tools/src/medianfilter.c
r20652 r36680 96 96 for (j = 0; j < Npixrd; j++, O++) { 97 97 Nvalid = 0; 98 int debug = FALSE && (n == 5) && (j >= 1776779) && (j <= 1776789); 98 99 for (k = 0; k < Nfiles; k++) { 99 100 v = (float *)tmpmatr[k].buffer; 101 if (debug) { 102 fprintf (stderr, "%8.2f ", v[j]); 103 } 100 104 if (v[j] < MinValid) continue; 101 if (isnan(v[j])) continue; 102 if (isinf(v[j])) continue; 103 list[k] = v[j]; 105 if (isnan(v[j])) { 106 continue; 107 } 108 if (isinf(v[j])) { 109 continue; 110 } 111 list[Nvalid] = v[j]; 104 112 Nvalid ++; 105 113 } 114 if (debug) fprintf (stderr, "\n"); 106 115 if (Nvalid == 0) { 107 *O = 0.0; 116 *O = NAN; 117 if (debug) { 118 fprintf (stderr, "Nvalid is 0\n"); 119 } 108 120 continue; 109 121 } … … 111 123 sum = 0; 112 124 Nval = 0; 125 if (debug) fprintf (stderr, "list : "); 113 126 for (k = fmin*Nvalid; k < fmax*Nvalid; k++) { 127 if (debug) { 128 fprintf (stderr, "%8.2f ", list[k]); 129 } 114 130 sum += list[k]; 115 131 Nval ++; 116 132 } 117 133 *O = (sum / Nval); 134 if (debug) { 135 fprintf (stderr, " = %f / %f = %f\n", sum, Nval, *O); 136 fprintf (stderr, "\n"); 137 } 118 138 } 119 139 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/uniphot/src/find_image_sgroups.c
r31160 r36680 22 22 coords.pc1_1 = coords.pc2_2 = 1.0; 23 23 coords.pc1_2 = coords.pc2_1 = 0.0; 24 strcpy (coords.ctype, " RA---TAN");24 strcpy (coords.ctype, "DEC--TAN"); 25 25 26 26 Ngroup = 0; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/uniphot/src/update_dvo_setphot.c
r35103 r36680 2 2 int update_dvo_setphot_parallel (SkyTable *sky, Image *image, off_t Nimage); 3 3 4 // XXX convert this to use the ImageSubset to save space 4 5 int update_dvo_setphot (Image *image, off_t Nimage, FlatCorrectionTable *flatcorr) { 5 6 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/uniphot/src/update_dvo_uniphot.c
r34088 r36680 61 61 coords.pc1_1 = coords.pc2_2 = 1.0; 62 62 coords.pc1_2 = coords.pc2_1 = 0.0; 63 strcpy (coords.ctype, " RA---TAN");63 strcpy (coords.ctype, "DEC--TAN"); 64 64 65 65 for (i = 0; i < pglob.gl_pathc; i++) {
Note:
See TracChangeset
for help on using the changeset viewer.
