Changeset 41379 for trunk/Ohana/src/opihi/cmd.astro
- Timestamp:
- Jun 22, 2020, 11:00:22 AM (6 years ago)
- Location:
- trunk/Ohana/src/opihi/cmd.astro
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.astro/coords.c
r37807 r41379 12 12 Vector *xvec = NULL; 13 13 Vector *yvec = NULL; 14 15 if ((N = get_argument (argc, argv, "-copy"))) { 16 Buffer *src = NULL; 17 18 remove_argument (N, &argc, argv); 19 if ((src = SelectBuffer (argv[N], OLDBUFFER, TRUE)) == NULL) goto escape; 20 21 if (!GetCoords (&coords, &src[0].header)) { 22 gprint (GP_ERR, "error getting WCS elements from src buffer %s\n", argv[N]); 23 return (FALSE); 24 } 25 26 remove_argument (N, &argc, argv); 27 28 if (argc != 2) goto syntax; 29 30 if ((buf = SelectBuffer (argv[1], OLDBUFFER, TRUE)) == NULL) goto escape; 31 if (!PutCoords (&coords, &buf[0].header)) { 32 gprint (GP_ERR, "error getting WCS elements from src buffer %s\n", argv[1]); 33 return (FALSE); 34 } 35 return TRUE; 36 } 14 37 15 38 MOSAIC = NULL; … … 116 139 syntax: 117 140 gprint (GP_ERR, "USAGE: coords [buffer] (-c R D) | (-p X Y)\n"); 118 gprint (GP_ERR, "only one of -p or -c can be used\n"); 141 gprint (GP_ERR, "USAGE: coords [tgtbuffer] (-copy srcbuffer)\n"); 142 gprint (GP_ERR, "only one of -p or -c or -copy can be used\n"); 119 143 gprint (GP_ERR, " -p : from pixels to ra/dec\n"); 120 144 gprint (GP_ERR, " -c : from ra/dec to pixels\n"); 121 145 gprint (GP_ERR, " coordinates are in degrees\n"); 146 gprint (GP_ERR, " -copy : copy coordinate WCS keywords from srcbuffer to tgtbuffer\n"); 122 147 escape: 123 148 if (MOSAIC != NULL) free (MOSAIC); -
trunk/Ohana/src/opihi/cmd.astro/init.c
r40376 r41379 34 34 int imsub PROTO((int, char **)); 35 35 int jdtolst PROTO((int, char **)); 36 int mjdtolst PROTO((int, char **)); 36 37 int medianmap PROTO((int, char **)); 37 38 int galsectors PROTO((int, char **)); … … 105 106 {1, "imsub", imsub, "subtract function"}, 106 107 {1, "jdtolst", jdtolst, "JD to LST conversion"}, 108 {1, "mjdtolst", mjdtolst, "MJD to LST conversion"}, 107 109 {1, "medianmap", medianmap, "small median image"}, 108 110 {1, "mkgauss", mkgauss, "generate a 2-D gaussian centered in image"}, -
trunk/Ohana/src/opihi/cmd.astro/jdtolst.c
r40376 r41379 23 23 char *long_str = get_variable ("LONGITUDE"); 24 24 if (!long_str) { 25 gprint (GP_ERR, "please define $LONGITUDE \n");25 gprint (GP_ERR, "please define $LONGITUDE (decimal hours, west positive)\n"); 26 26 FREE (OutputName); 27 27 return FALSE; 28 28 } 29 29 double longitude = atof (long_str); 30 if (VERBOSE) gprint (GP_ERR, "using longitude of %f \n", longitude);30 if (VERBOSE) gprint (GP_ERR, "using longitude of %f (decimal hours, west positive)\n", longitude); 31 31 free (long_str); 32 32 … … 87 87 gprint (GP_ERR, " (JD) may be a number or a vector.\n"); 88 88 gprint (GP_ERR, " if (JD) is a vector, (output) must be supplied and is used as the name of the output vector \n"); 89 gprint (GP_ERR, " $LONGITUDE must be set (decimal hours, west positive)\n"); 89 90 return (FALSE); 90 91 } 92 93 # define MJD_OFFSET 2400000.5 94 95 int mjdtolst (int argc, char **argv) { 96 97 int N; 98 Vector *mjdvec, *outvec; 99 100 int VERBOSE = FALSE; 101 VERBOSE = FALSE; 102 if ((N = get_argument (argc, argv, "-v"))) { 103 VERBOSE = TRUE; 104 remove_argument (N, &argc, argv); 105 } 106 107 char *OutputName = NULL; 108 if ((N = get_argument (argc, argv, "-output"))) { 109 remove_argument (N, &argc, argv); 110 OutputName = strcreate (argv[N]); 111 remove_argument (N, &argc, argv); 112 } 113 if (argc != 2) goto syntax; 114 115 char *long_str = get_variable ("LONGITUDE"); 116 if (!long_str) { 117 gprint (GP_ERR, "please define $LONGITUDE (decimal hours, west positive)\n"); 118 FREE (OutputName); 119 return FALSE; 120 } 121 double longitude = atof (long_str); 122 if (VERBOSE) gprint (GP_ERR, "using longitude of %f (decimal hours, west positive)\n", longitude); 123 free (long_str); 124 125 if (ISNUM(argv[1][0])) { 126 127 char *endptr; 128 double mjd = strtod (argv[1], &endptr); 129 if (endptr == argv[1]) { 130 gprint (GP_ERR, "error interpretting %s as a number\n", argv[1]); 131 FREE (OutputName); 132 return FALSE; 133 } 134 135 double lst = ohana_lst (mjd + MJD_OFFSET, longitude); 136 137 if (OutputName) { 138 set_variable (OutputName, lst); 139 FREE (OutputName); 140 return (TRUE); 141 } 142 143 gprint (GP_ERR, "lst: %f\n", lst); 144 return (TRUE); 145 } 146 147 if (!OutputName) { 148 gprint (GP_ERR, " if (MJD) is a vector, -output must be supplied\n"); 149 return FALSE; 150 } 151 152 if ((mjdvec = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) { 153 FREE (OutputName); 154 return FALSE; 155 } 156 157 if (mjdvec->type != OPIHI_FLT) { 158 gprint (GP_ERR, " (MJD) must be of type FLOAT\n"); 159 FREE (OutputName); 160 return FALSE; 161 } 162 163 if ((outvec = SelectVector (OutputName, ANYVECTOR, TRUE)) == NULL) { 164 FREE (OutputName); 165 return FALSE; 166 } 167 168 ResetVector (outvec, OPIHI_FLT, mjdvec[0].Nelements); 169 170 for (int i = 0; i < mjdvec[0].Nelements; i++) { 171 double lst = ohana_lst (mjdvec->elements.Flt[i] + MJD_OFFSET, longitude); 172 outvec->elements.Flt[i] = lst; 173 } 174 FREE (OutputName); 175 return TRUE; 176 177 syntax: 178 gprint (GP_ERR, "USAGE: mjdtolst (MJD) [-output name]\n"); 179 gprint (GP_ERR, " (MJD) may be a number or a vector.\n"); 180 gprint (GP_ERR, " if (MJD) is a vector, (output) must be supplied and is used as the name of the output vector \n"); 181 gprint (GP_ERR, " $LONGITUDE must be set (decimal hours, west positive)\n"); 182 return (FALSE); 183 }
Note:
See TracChangeset
for help on using the changeset viewer.
