Changeset 41340 for trunk/Ohana/src/opihi/cmd.astro/region.c
- Timestamp:
- Apr 16, 2020, 1:54:47 PM (6 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/cmd.astro/region.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.astro/region.c
r41158 r41340 3 3 int region (int argc, char **argv) { 4 4 5 double Ra, Dec ;5 double Ra, Dec, Radius; 6 6 float dx, dy; 7 7 int N, kapa, NoClear, dXpix, dYpix; … … 54 54 } 55 55 56 float XSIZE = NAN;57 if ((N = get_argument (argc, argv, "-xsize"))) {58 remove_argument (N, &argc, argv);59 XSIZE = atof (argv[N]);60 remove_argument (N, &argc, argv);61 if (XSIZE <= 0) {62 gprint (GP_ERR, "ERROR: xsize <= 0\n");63 return FALSE;64 }65 }66 67 float YSIZE = NAN;68 if ((N = get_argument (argc, argv, "-ysize"))) {69 remove_argument (N, &argc, argv);70 YSIZE = atof (argv[N]);71 remove_argument (N, &argc, argv);72 if (YSIZE <= 0) {73 gprint (GP_ERR, "ERROR: xsize <= 0\n");74 return FALSE;75 }76 }77 78 56 if ((N = get_argument (argc, argv, "-ew"))) { 79 57 remove_argument (N, &argc, argv); … … 103 81 } 104 82 105 int RadiusArg, CtypeArg; 106 if (!isnan(XSIZE) || !isnan(YSIZE)) { 107 RadiusArg = -1; 108 CtypeArg = 3; 109 if ((argc != 3) && (argc != 4)) { 110 gprint (GP_ERR, "USAGE: region Ra Dec [projection] [-xsize deg] [-ysize deg]\n"); 111 gprint (GP_ERR, " OR: region Ra Dec Radius [projection]\n"); 83 if ((argc != 4) && (argc != 5)) { 84 gprint (GP_ERR, "USAGE: region Ra Dec Radius [projection] [orientation]\n"); 112 85 gprint (GP_ERR, " [-image] [-ew] [+ew] [-ns] [+ns] [-no-clear] [-angle theta]\n"); 113 86 gprint (GP_ERR, " current: %f %f (%f x %f) (%s)\n", … … 117 90 &graphmode.coords.ctype[5]); 118 91 return (FALSE); 119 } 120 } else { 121 RadiusArg = 3; 122 CtypeArg = 4; 123 if ((argc != 4) && (argc != 5)) { 124 gprint (GP_ERR, "USAGE: region Ra Dec Radius [projection]\n"); 125 gprint (GP_ERR, " OR: region Ra Dec [projection] [-xsize deg] [-ysize deg]\n"); 126 gprint (GP_ERR, " [-image] [-ew] [+ew] [-ns] [+ns] [-no-clear] [-angle theta]\n"); 127 gprint (GP_ERR, " current: %f %f (%f x %f) (%s)\n", 128 graphmode.coords.crval1, graphmode.coords.crval2, 129 fabs(graphmode.xmax - graphmode.xmin), 130 fabs(graphmode.ymax - graphmode.ymin), 131 &graphmode.coords.ctype[5]); 132 return (FALSE); 133 } 134 } 92 } 93 135 94 if (!ohana_str_to_radec (&Ra, &Dec, argv[1], argv[2])) return (FALSE); 95 Radius = atof (argv[3]); 96 InitCoords (&graphmode.coords, "DEC--TAN"); 136 97 137 // region 0 0 sin -- should raise an error (radius = 0 or non-numeric) 138 139 // I want to be able to support the old style call in which both of these were valid: 140 // region 0 0 90 ait 141 // region 0 0 90 <- uses existing, sticky projection type 142 // but I also want to be able to use 143 // region 0 0 ait -xsize 5 144 // region 0 0 ait -ysize 5 145 146 double Radius = NAN; 147 if (RadiusArg >= 0) { 148 Radius = atof (argv[RadiusArg]); 98 if (argc == 5) { 99 if (!strcasecmp (argv[4], "TAN")) 100 strcpy (graphmode.coords.ctype, "DEC--TAN"); 101 if (!strcasecmp (argv[4], "SIN")) 102 strcpy (graphmode.coords.ctype, "DEC--SIN"); 103 if (!strcasecmp (argv[4], "ARC")) 104 strcpy (graphmode.coords.ctype, "DEC--ARC"); 105 if (!strcasecmp (argv[4], "STG")) 106 strcpy (graphmode.coords.ctype, "DEC--STG"); 107 if (!strcasecmp (argv[4], "ZEA")) 108 strcpy (graphmode.coords.ctype, "DEC--ZEA"); 109 if (!strcasecmp (argv[4], "AIT")) 110 strcpy (graphmode.coords.ctype, "DEC--AIT"); 111 if (!strcasecmp (argv[4], "GLS")) 112 strcpy (graphmode.coords.ctype, "DEC--GLS"); 113 if (!strcasecmp (argv[4], "PAR")) 114 strcpy (graphmode.coords.ctype, "DEC--PAR"); 149 115 } 150 151 InitCoords (&graphmode.coords, "DEC--TAN");152 if (argc == CtypeArg + 1) {153 if (!strcasecmp (argv[CtypeArg], "TAN")) { strcpy (graphmode.coords.ctype, "DEC--TAN"); goto got_ctype; }154 if (!strcasecmp (argv[CtypeArg], "SIN")) { strcpy (graphmode.coords.ctype, "DEC--SIN"); goto got_ctype; }155 if (!strcasecmp (argv[CtypeArg], "ARC")) { strcpy (graphmode.coords.ctype, "DEC--ARC"); goto got_ctype; }156 if (!strcasecmp (argv[CtypeArg], "STG")) { strcpy (graphmode.coords.ctype, "DEC--STG"); goto got_ctype; }157 if (!strcasecmp (argv[CtypeArg], "ZEA")) { strcpy (graphmode.coords.ctype, "DEC--ZEA"); goto got_ctype; }158 if (!strcasecmp (argv[CtypeArg], "AIT")) { strcpy (graphmode.coords.ctype, "DEC--AIT"); goto got_ctype; }159 if (!strcasecmp (argv[CtypeArg], "GLS")) { strcpy (graphmode.coords.ctype, "DEC--GLS"); goto got_ctype; }160 if (!strcasecmp (argv[CtypeArg], "PAR")) { strcpy (graphmode.coords.ctype, "DEC--PAR"); goto got_ctype; }161 gprint (GP_ERR, "ERROR: invalid projection type %s\n", argv[CtypeArg]);162 gprint (GP_ERR, "allowed values: TAN, SIN, ARC, STG, ZEA, AIT, GLS, PAR\n");163 return FALSE;164 }165 got_ctype:166 116 167 117 graphmode.coords.crval1 = Ra; … … 176 126 graphmode.coords.pc2_2 = cos(Angle*RAD_DEG)*pc2_2; 177 127 178 // ask kapa for coordinate limits, to get the right aspect ratio 179 // dx, dy are the size of the graph region in pixels 128 /* ask kapa for coordinate limits, to get the right aspect ratio */ 180 129 KapaGetLimits (kapa, &dx, &dy); 181 130 dx = fabs (dx); … … 183 132 184 133 /* define limits for Ra, Dec at center, grid in degrees */ 185 if (RadiusArg >= 0) { 186 // force non-anamorphic projection with Radius set to smaller axis 187 if (dy < dx) { 188 graphmode.xmin = -(dx/dy)*Radius; 189 graphmode.ymin = -Radius; 190 graphmode.xmax = (dx/dy)*Radius; 191 graphmode.ymax = Radius; 192 } else { 193 graphmode.xmin = -Radius; 194 graphmode.ymin = -(dy/dx)*Radius; 195 graphmode.xmax = Radius; 196 graphmode.ymax = (dy/dx)*Radius; 197 } 134 if (dy < dx) { 135 graphmode.xmin = -(dx/dy)*Radius; 136 graphmode.ymin = -Radius; 137 graphmode.xmax = (dx/dy)*Radius; 138 graphmode.ymax = Radius; 198 139 } else { 199 if (isnan(XSIZE)) { 200 graphmode.xmin = -(dx/dy)*YSIZE/2.0; 201 graphmode.ymin = -YSIZE/2.0; 202 graphmode.xmax = (dx/dy)*YSIZE/2.0; 203 graphmode.ymax = YSIZE/2.0; 204 } 205 if (isnan(YSIZE)) { 206 graphmode.xmin = -XSIZE/2.0; 207 graphmode.ymin = -(dy/dx)*XSIZE/2.0; 208 graphmode.xmax = XSIZE/2.0; 209 graphmode.ymax = (dy/dx)*XSIZE/2.0; 210 } 211 // anamorphic projection: 212 if (!isnan(XSIZE) && !isnan(YSIZE)) { 213 graphmode.xmin = -XSIZE/2.0; 214 graphmode.ymin = -YSIZE/2.0; 215 graphmode.xmax = XSIZE/2.0; 216 graphmode.ymax = YSIZE/2.0; 217 } 218 } 140 graphmode.xmin = -Radius; 141 graphmode.ymin = -(dy/dx)*Radius; 142 graphmode.xmax = Radius; 143 graphmode.ymax = (dy/dx)*Radius; 144 } 219 145 220 146 set_variable ("XMIN", graphmode.xmin);
Note:
See TracChangeset
for help on using the changeset viewer.
