#include #include #include #include #include #include "obs.h" #include "vlbconst.h" #include "vlbutil.h" #include "telspec.h" #include "visplot.h" #include "vplot.h" #include "cpgplot.h" #include "logio.h" /* * Define the selection keys. */ enum { KEY_NONE='\0', /* Null key press */ KEY_HELP='H', /* Key to list usage information */ KEY_UT ='U', /* Key to select UT input mode */ KEY_INT =' ', /* Enter integration based flagging mode */ KEY_REST='R', /* Key to introduce boxed-restore */ KEY_CUT ='C', /* Key to introduce cutting */ KEY_FLG ='F', /* Toggle display of flagged data */ KEY_ERR ='E', /* Toggle display of error bars */ KEY_IF ='I', /* Toggle IF editing mode */ KEY_CH ='W', /* Toggle channel editing mode */ KEY_FUL ='V', /* Key to select full display range */ KEY_DIS ='L', /* Key to redisplay the current plot */ KEY_NXT ='N', /* Key to display the next baseline */ KEY_ORDER='O', /* Toggle baseline ordering */ KEY_PRV ='P', /* Key to display the previous baseline */ KEY_TEL ='T', /* Key to request keyboard input reference-telescope */ KEY_CUR ='A', /* Key for cursor position input */ KEY_CAN ='D', /* Key to cancel incomplete select range */ KEY_MOD ='M', /* Toggle model plotting */ KEY_QUIT='X', /* Key to quit from this function */ KEY_NUMB='S', /* Split into keyboard specified number of sub-plots */ KEY_BRK ='B', /* Toggle breaking into scans */ KEY_ZAP ='K', /* Zap points within a scan (only one baseline at a time) */ KEY_ZOOM='Z', /* Zoom in or out wrt amplitude or phase */ KEY_AMP ='1', /* Display only amplitudes */ KEY_PHS ='2', /* Display only phases */ KEY_BOTH='3', /* Display both amplitudes and phases */ KEY_PRVIF='[', /* Show the previous IF */ KEY_NXTIF=']', /* Show the next IF */ KEY_CROSS='+' /* Toggle cross-hair cursor mode */ }; static const int cutcol=2; /* PGPLOT color index for cut edit window */ static const int rescol=10; /* PGPLOT color index for restore edit window */ static const int zoomcol=5; /* PGPLOT color index for zoom cursor window */ static int v_box(Vedpar *vp, int doflag); static int v_find(Vedpar *vp, Vissub *vs, float utval, float value, int isamp); static int v_edit(Vedpar *vp, Vissub *vs, int flag, int ut); static int v_toggle(Vedpar *vp, Vissub *vs, float utval, float value, int wasamp); static int v_newut(Vedpar *vp); static int v_zoom(Vedpar *vp); static int v_newnum(Vedpar *vp); static int v_flags(Vedpar *vp, int key, int waslow); /*....................................................................... * Receive input of new UT range via the cursor and redisplay the plot * within that range. If the user presses the KEY_UT key then display * the full UT range. * * Input: * vp Vedpar * The visibility plot attributes to supply to visplt(). * Output: * return int 0 - OK. Anything else denotes a fatal error. */ static int v_newut(Vedpar *vp) { int accepted; /* True when cursor entry accepted */ int dofull=0; /* True if full UT range requested */ int iter; /* Iterate over getting two valid keypresses */ float utval[2]={0.0f,0.0f}; /* The two UT end points wrt vp->utref. */ /* * Get the first cursor position for the new UT range. */ for(iter=0; iter<2 && !dofull; iter++) { do { if(v_cursor(vp, 1, iter==0?B_XVAL:B_XRNG, 0, NULL, utval[0], 0.0f, zoomcol)) return 1; accepted = 0; switch(vp->cursor.key) { case KEY_UT: /* Revert to the full UT range */ accepted = dofull = 1; break; case KEY_QUIT: case KEY_CAN: /* Abort UT selection */ return 0; break; case KEY_CUR: /* Accept the selected UT */ accepted=1; utval[iter] = vp->cursor.utval; break; default: /* Unexpected cursor input key - show usage */ printf("\nUT range selection:\n"); printf(" %c - Select the %s UT.\n", KEY_CUR, iter==0 ? "start" : "end"); printf(" %c - Abort selection.\n", KEY_CAN); printf(" %c - Revert to the full UT range.\n", KEY_UT); break; }; } while(!accepted); }; /* * Get the UT indexes. */ if(dofull) { vp->uta = 0; vp->utb = vp->sub->ntime - 1; } else { int ut; /* UT index loop variable */ Integration *integ; /* Descriptor of integration = sub->integ[ut] */ double utmin = utval[0] + vp->utref; double utmax = utval[1] + vp->utref; /* * Swap the range limits such that utmin < utmax. */ if(utmin>utmax) {double dtmp=utmin; utmin=utmax; utmax=dtmp;}; /* * Locate the equivalent ut indexes to the selected ut values. */ for(ut=vp->uta,integ = &vp->sub->integ[ut]; ututb && integ->ut < utmin; ut++,integ++); vp->uta = ut; for(ut=vp->uta; ut<=vp->utb && integ->ut <= utmax; ut++,integ++); vp->utb = (vp->utauta; }; /* * Display the result. */ return v_redisp(vp); } /*....................................................................... * Allow the user to zoom in or out in amplitude or phase. * * Input: * vp Vedpar * The visibility plot attributes to supply to visplt(). * Output: * return int 0 - OK. Anything else means fatal error. */ static int v_zoom(Vedpar *vp) { int dofull=0; /* True if full phase range requested */ int iter; /* Iterate over getting two valid keypresses */ float value[2]={0.0f,0.0f}; /* The two selected values */ float wasamp=0; /* True if the first value was an amplitude */ Vissub *vs=NULL;/* The descriptor of the first sub-plot selected */ /* * Get the two cursor selections. */ for(iter=0; iter<2 && !dofull; iter++) { int accepted = 0; while(!accepted) { if(v_cursor(vp, 1, iter==0?B_YVAL:B_YRNG, wasamp, vs, vp->utmin, value[0], zoomcol)) return 1; switch(vp->cursor.key) { case KEY_ZOOM: /* Display full range and end phase range selection */ accepted = dofull = 1; break; case KEY_QUIT: case KEY_CAN: /* Abort selection */ return 0; break; case KEY_CUR: /* Accept the selected value */ if(iter==1 && vp->cursor.value == value[0]) { printf("Second value identical to first. Selection aborted.\n"); return 0; } else if(iter==1 && (!wasamp != !vp->cursor.wasamp || vp->cursor.vs != vs)) { printf("Second selection in a different sub-plot. Selection aborted.\n"); return 0; } else { vs = vp->cursor.vs; wasamp = vp->cursor.wasamp; value[iter] = vp->cursor.value; accepted=1; }; break; default: /* Unexpected cursor input key - show usage */ printf("\nAmplitude or phase range selection:\n"); printf(" %c - Select the %s value of the range.\n", KEY_CUR, iter==0 ? "start":"end"); printf(" %c - Abort selection.\n", KEY_CAN); printf(" %c - Revert to the full range.\n", KEY_ZOOM); break; }; }; }; /* * Assign the selected range. */ if(dofull) { /* Full data range? */ vp->ampmin = vp->ampmax = 0.0f; /* This enables autoscaling */ vp->phsmin = -pi; vp->phsmax = pi; } else { /* * Sort the values into ascending order. */ if(value[0] > value[1]) { float newval = value[0]; value[0] = value[1]; value[1] = newval; }; /* * Install the new limits. */ if(wasamp) { vp->ampmin = value[0]; vp->ampmax = value[1]; } else { vp->phsmin = value[0]; vp->phsmax = value[1]; }; }; /* * Display the result. */ return v_redisp(vp); } /*....................................................................... * Allow a range box to be selected and optionally either flag all points * above and below the box, or restore all points inside the box. * * Input: * vp Vedpar * The visibility plot attributes to supply to visplt(). * doflag int If true flag data within box. If false unflag * everything within the box. * Output: * return int 0 - OK. Anything else means fatal error. */ static int v_box(Vedpar *vp, int doflag) { Integration *integ; /* Descriptor of an integration in the select box */ int ut; /* UT index loop variable */ Vissub *vs=NULL; /* Plot in which cursor was pressed */ int accepted; /* True when cursor entry accepted */ float utrefc=0.0f; /* Reference cursor UT wrt vp->utref */ double utmin=0.0; /* Start of the selected ut range */ double utmax=0.0; /* End of the selected ut range */ float valrefc=0.0f;/* Reference cursor value */ float minval=0.0f;/* Lower of value[0] and value[1] */ float maxval=0.0f;/* higher of value[0] and value[1] */ int wasamp=0; /* True when first selection was an amplitude */ int iter; /* Iterate over getting two valid keypresses */ /* * Get the first cursor position. */ for(iter=0; iter<2; iter++) { do { if(v_cursor(vp, 1, iter==0 ? B_NORM:B_RECT, wasamp, vs, utrefc, valrefc, doflag ? cutcol:rescol)) return 1; accepted = 0; switch(vp->cursor.key) { case KEY_QUIT: case KEY_CAN: /* Abort box selection */ return 0; break; case KEY_CUR: /* Accept the selected vertex */ if(iter==0) { utrefc = vp->cursor.utval; valrefc = vp->cursor.value; utmin = utmax = utrefc; minval = maxval = valrefc; vs = vp->cursor.vs; wasamp = vp->cursor.wasamp; } else { if(vp->cursor.vs != vs || !wasamp != !vp->cursor.wasamp) { fprintf(stderr, "Select box spans more than one plot.\n"); return 0; }; if(vp->cursor.utval < utmin) utmin = vp->cursor.utval; else utmax = vp->cursor.utval; if(vp->cursor.value < minval) minval = vp->cursor.value; else maxval = vp->cursor.value; }; accepted=1; break; default: /* Unexpected cursor input key - show usage */ printf("\nSelect %s box.\n", doflag ? "flagging":"restore"); printf(" %c - Select %s corner.\n", KEY_CUR, iter==0 ? "first":"opposite"); printf(" %c - Abort selection.\n", KEY_CAN); break; }; } while(!accepted); }; /* * Get the ut values. */ utmin += vp->utref; utmax += vp->utref; /* * Buffer PGPLOT instructions while the points are redrawn. */ cpgbbuf(); /* * Only flag points in the UT range selected. */ for(ut=vp->uta,integ = &vp->sub->integ[ut]; ut<=vp->utb; ut++,integ++) { double vlbut = integ->ut; if(vlbut >= utmin && vlbut <= utmax) { /* Only flag in given UT range */ Visibility *vis = &integ->vis[vs->base]; /* * Ignore deleted points. */ if(!(vis->bad & FLAG_DEL)) { int inside; /* True if the visibility is inside select-box */ /* * Determine whether the current point is inside or outside the * select-box. */ if(wasamp) inside = vis->amp >= minval && vis->amp <= maxval; else { float phs = vis->phs - twopi * floor(vis->phs/twopi + 0.5); inside = phs >= minval && phs <= maxval; }; /* * Edit and redisplay the point in all relevant sub-plots. */ if(inside && v_edit(vp, vs, doflag, ut)) return 1; }; }; }; cpgebuf(); /* Plotting complete - end plot buffering */ return 0; } /*....................................................................... * Flag all points within the scan and baseline selected by the cursor. * * Input: * vp Vedpar * The visibility plot attributes to supply to visplt(). * vs Vissub * The sub-plot descriptor returned by v_cursor(). * (If vs==NULL, -1 is returned). * sc Scans * The scan descritptor returned by v_cursor(). * (If sc==NULL, -1 is returned). * doflag int If true flag data within box. If false unflag * everything within the box. * Output: * return int 0 - OK. Anything else means fatal error. */ static int v_zap(Vedpar *vp, Vissub *vs, Scans *sc, int doflag) { Integration *integ; /* Descriptor of an integration */ int ut; /* UT index loop variable */ int ierr=0; /* Error status flag */ int save_mode; /* Used to record station/baseline editing mode */ double utmin; /* Start of the selected ut range */ double utmax; /* End of the selected ut range */ double vlbut; /* The ut being considered */ /* * Ignore call if the cursor was not pressed within a plot. */ if(vs==NULL || sc==NULL) return 0; /* * Get the ut values of the start and end of the scan. */ utmin = sc->utmin + vp->utref; utmax = sc->utmax + vp->utref; /* * Buffer PGPLOT instructions while the points are redrawn. */ cpgbbuf(); /* * Turn off station editing. */ save_mode = vp->stat_ed; vp->stat_ed = 0; /* * Only flag points in the UT range selected. */ for(ut=vp->uta, integ = &vp->sub->integ[ut]; !ierr && ut<=vp->utb; ut++,integ++) { vlbut = integ->ut; if(vlbut >= utmin && vlbut <= utmax) { /* Only flag in given UT range */ Visibility *vis = &integ->vis[vs->base]; /* * Ignore deleted points. */ if(vis->bad & FLAG_DEL) continue; /* * Edit and redisplay the point. */ ierr = v_edit(vp, vs, doflag, ut); }; }; vp->stat_ed = save_mode; /* Restore station/baseline editing mode. */ cpgebuf(); /* Plotting complete - end plot buffering */ return ierr; } /*....................................................................... * Take a cursor position returned by v_cursor() and locate the index * of the closest plotted point. * * Input: * vp Vedpar * The plot descriptor. * vs Vissub * The sub-plot descriptor returned by v_cursor(). * (If vs==NULL, -1 is returned). * utval float The relative UT returned by v_cursor(). * value float The amp or phase returned by v_cursor(). * isamp int The point type returned by v_cursor(). * Output: * return int The integration index of the nearest point or * -1 if no displayed data in zone where cursor * was pressed. */ static int v_find(Vedpar *vp, Vissub *vs, float utval, float value, int isamp) { Integration *integ;/* Descriptor of an integration */ int ut; /* The integration index being checked */ double vlbut; /* The ut selected */ float xtomm,ytomm; /* Conversion factor between world coords and mm */ int bestut=0; /* The ut index of the point closest to the cursor */ float xdif; /* X Distance in mm between data point and cursor */ float ydif; /* Y Distance in mm between data point and cursor */ float dist; /* The squared dist (mm) from data point to cursor */ float mindist=0.0f;/* The min value of 'dist' */ float phs; /* A visibility phase wrapped into the range -pi to pi */ int first=1; /* True until end of first iteration of search loop */ /* * Cursor pressed outside of any plot? */ if(vs==NULL) return -1; /* * Determine conversion factors from world coords to mm. */ if(v_scale(vp, vs, isamp, &xtomm, &ytomm)) return -1; /* * Calculate the ut corresponding to utval. */ vlbut = utval + vp->utref; /* * Locate the nearest point. */ for(ut=vp->uta, integ = &vp->sub->integ[ut]; ut<=vp->utb; ut++,integ++) { Visibility *vis = &integ->vis[vs->base]; xdif = xtomm * (integ->ut - vlbut); /* * Ignore deleted points. Also ignore flagged data if not displayed.. */ if((vis->bad & FLAG_DEL) || (vis->bad && !vp->doflag)) continue; /* * Determine the amplitude or phase difference dependant upon which * partition of the plot recieved the cursor press. */ if(isamp) ydif = ytomm * (value - vis->amp); else { phs = vis->phs - twopi * floor(vis->phs/twopi + 0.5); ydif = ytomm * (value - phs); }; /* * Compare the squared distance from this point with the that of * the previous closest point. */ dist = xdif*xdif + ydif*ydif; if(first || dist < mindist) { first = 0; bestut = ut; mindist = dist; }; }; /* * No points in plot! */ if(first) return -1; return bestut; } /*....................................................................... * Edit one point (by baseline or station) and redisplay on each * respective displayed sub-plot. * * Input: * vp Vedpar * The plot descriptor. * vs Vissub * The sole baseline to be editted if vp->stat_ed==0. * flag int If true, flag unflagged data. If false, restore * flagged data. * ut int The index of the integration to be editted. * Output: * return int 0 - OK. */ static int v_edit(Vedpar *vp, Vissub *vs, int flag, int ut) { Observation *ob; /* The descriptor of the observation being edited */ Subarray *sub; /* The descriptor of the displayed sub-array */ int iplot; /* Sub-plot index */ int ierr=0; /* Error status */ /* * Check descriptors. */ if(vp==NULL || (!vp->stat_ed && vs==NULL)) { lprintf(stderr, "v_edit: NULL %s descriptor intercepted\n", vp==NULL?"plot":"sub-plot"); return 1; }; /* * Get the descriptor of the observation and sub-array being edited. */ ob = vp->ob; sub = vp->sub; /* * This function modifies the data. */ vp->modified = 1; /* * Start by erasing the given integration from all relevant sub-plots. */ cpgbbuf(); /* Buffer changes */ if(vp->stat_ed) { for(iplot=0; !ierr && iplotnplot; iplot++) ierr = v_pldata(vp, &vp->vplots[iplot], ut, ut, 1); } else { ierr = v_pldata(vp, vs, ut, ut, 1); }; /* * Now edit the point on all relevant baselines. */ if(!ierr) { ierr = ed_integ(ob, vp->sub, ut, ob->stream.cif, flag, !vp->stat_ed, vp->stat_ed, vp->ch_ed, vp->if_ed, vp->stat_ed ? vp->bs_beg.ta:vs->base); }; /* * Re-plot the given integration on all relevant sub-plots. */ if(!ierr) { if(vp->stat_ed) { for(iplot=0; !ierr && iplotnplot; iplot++) ierr = v_pldata(vp, &vp->vplots[iplot], ut, ut, 0); } else { ierr = v_pldata(vp, vs, ut, ut, 0); }; }; /* End of If no error occurred while editing points */ /* * End pgplot buffering. */ cpgebuf(); return 0; } /*....................................................................... * Given the values returned by v_cursor(), toggle the flagged status of * the integration closest to the cursor. * * Input: * vp Vedpar * The plot descriptor. * vs Vissub * The sub-plot descriptor returned by v_cursor(). * utval float The UT value returned by v_cursor(). * value float The amp or phase returned by v_cursor(). * wasamp int Type of 'value', returned by v_cursor(). * Output: * return int 0 - OK. */ static int v_toggle(Vedpar *vp, Vissub *vs, float utval, float value, int wasamp) { Visibility *vis; /* The nearest visibility */ int ut; /* The index of the nearest integration */ /* * Find the nearest integration on the specified baseline. */ ut = v_find(vp, vs, utval, value, wasamp); if(ut < 0) return 0; /* Ignore failed locations */ /* * Toggle the status of the visibility and propogate effects * into other effected baselines. */ vis = &vp->sub->integ[ut].vis[vs->base]; return v_edit(vp, vs, !(vis->bad & FLAG_BAD), ut); } /*....................................................................... * Request a new value for the number of sub-plots per page. * * Input: * vp Vedpar * The plot descriptor. * Output: * return int 0 - OK. */ static int v_newnum(Vedpar *vp) { char awrk[81]; /* Temporary work array */ char *cptr; /* Pointer into awrk[] */ long nrow; /* New number of plots. */ /* * Get the new number from the user. */ printf("Enter the required number of plots per page: "); if(fgets(awrk, sizeof(awrk)-1, stdin) == NULL) { fprintf(stderr, "Error reading input.\n"); return 0; }; /* * Skip leading white-space. */ cptr = awrk; while(*cptr && isspace(*cptr)) cptr++; /* * Read the number. */ nrow = *cptr ? strtol(cptr, &cptr, 10) : 0; /* * Skip trailing white-space. */ while(*cptr && isspace(*cptr)) cptr++; if(*cptr != '\0' || nrow < 0) { fprintf(stderr, "Unexpected input (not a positive integer).\n"); return 0; }; /* * Register the requested change in numbers of plot slots. */ v_setnrow(vp, (int) nrow); /* * Plot the new number of plots. */ return v_plot(vp, V_REPLOT, 1, NULL) < 0; } /*....................................................................... * Cursor control interface to plotting and editing functions. * * Input: * ob Observation * The descriptor of the observation to be plotted. * bs Basespec * The descriptor of the first baseline to be plotted. * If NULL, the default is the first baseline in the * observation. * cif int The index of the start IF, or -1 for the default. * nrow int Number of sub-plots in Y. * npage int The max number of pages to plot if non-interactive. * A value of 0 means no page limit. * docurs int If true allow cursor control if device has a cursor. * opts char * An optional string of flag toggling keys that * toggle after the values below have been applied. * Send NULL or empty string if not required. * doscan int If true break up plot into scans if present. * doamp int If true plot amplitude part of sub-plots. * dophs int If true plot phase part of sub-plots. * doflag int If true plot flagged data in addition to unflagged. * domod int If true plot model data in addition to unflagged. * dobars int If true plot error bars. * showall int If true, take account of flagged data in autoscaling. * Input/Output: * modified int * If modified!=NULL then *modified will be assigned * with 0 if no data were edited and 1 if data were * edited. * Output: * return int 0 - OK. */ int vedit(Observation *ob, Basespec *bs, int cif, int nrow, int npage, int docurs, char *opts, int doscan, int doamp, int dophs, int doflag, int domod, int dobars, int showall, int *modified) { Vedpar *vp; /* Plot descriptor */ int ierr=0; /* Error status */ int finished=0; /* True when user quits */ int old_if; /* State of current IF to be restored on exit */ int i; /* * Data not modified yet. */ if(modified!=NULL) *modified = 0; /* * Is the observation ready to be plotted? */ if(!ob_ready(ob, OB_SELECT, "vedit")) return 1; /* * If no baseline specification has been provided, override with the * default. */ if((bs && next_base(ob, FIND_FIRST, 1, 2, 1, 0, 1, bs)) || (!bs && !(bs=find_base(ob, 0, 0, 0, 0, 1, 2, 1, 0, 1)))) return 1; /* * Store the state of the current IF. */ old_if = get_cif_state(ob); /* * Allocate and initialize the plot descriptor. */ vp = new_Vedpar(ob, cif, docurs, doscan, doamp, dophs, doflag, domod, dobars, showall, nrow); if(vp==NULL) return 1; /* * If a string of flag options was given, interpret them here. */ if(opts != NULL) { size_t slen = strlen(opts); for(i=0; istat_ed = !vp->stat_ed; /* Toggle station/baseline flagging */ break; case KEY_IF: vp->if_ed = !vp->if_ed; /* Toggle IF flagging */ break; case KEY_CH: vp->ch_ed = !vp->ch_ed; /* Toggle channel flagging */ break; case KEY_ORDER: vp->doall = !vp->doall; break; case KEY_CROSS: vp->docross = !vp->docross; break; }; }; }; /* * Plot the first page. */ ierr = v_plot(vp, V_ALLNEW, 1, bs) <= 0; /* * Interactive plotting? */ if(vp->docurs) { /* * Interactive mode - Inform user of the way to receive usage information. */ lprintf(stdout, "For help move the cursor into the plot window and press \'%c\'.\n", KEY_HELP); /* * Start the interactive display/editing loop. */ while(!finished && ierr==0) { int wasflag=0; /* True if last key stroke toggled a flag */ int nflag=0; /* Number of flag toggling operations done */ /* * Read the cursor. */ do { ierr = v_cursor(vp, 0, B_NORM, 0, NULL, 0.0f, 0.0f, 1); /* * Toggle flags where appropriate. */ wasflag = v_flags(vp, vp->cursor.key, vp->cursor.waslow) == 0; nflag += wasflag; } while(wasflag); /* Don't do anything more if a flag was toggled */ /* * Take action appropriate to the key that the user pressed. */ if(nflag > 0) { /* Update display after a sequence of flag toggling */ nflag = 0; ierr = v_plot(vp, V_REPLOT, 1, NULL) < 0; } else { switch (vp->cursor.key) { case KEY_INT: /* Toggle flagging mode */ ierr = v_newmode(vp, !vp->stat_ed, vp->if_ed, vp->ch_ed); break; case KEY_IF: /* Toggle IF editing mode */ ierr = v_newmode(vp, vp->stat_ed, !vp->if_ed, vp->ch_ed); break; case KEY_CH: /* Toggle channel editing mode */ ierr = v_newmode(vp, vp->stat_ed, vp->if_ed, !vp->ch_ed); break; case KEY_DIS: /* Re-display current baseline */ ierr = v_plot(vp, V_REPLOT, 1, NULL) < 0; break; case KEY_NXT: /* Plot next page */ ierr = v_plot(vp, vp->cursor.waslow ? V_NXT_TB:V_NXTSUB, 1, NULL) < 0; break; case KEY_PRV: /* Plot previous page */ ierr = v_plot(vp, vp->cursor.waslow ? V_NXT_TB:V_NXTSUB, 0, NULL) < 0; break; case KEY_PRVIF: case KEY_NXTIF: { int step = vp->cursor.key==KEY_NXTIF ? 1 : -1; int cif = nextIF(ob, ob->stream.cif + step, 1, step); ierr = cif >= 0 && (getIF(ob, cif) || v_redisp(vp)); }; break; case KEY_TEL: /* New reference telescope */ /* * Get the user telescope/baseline request and plot the result. */ bs = read_Basespec(ob, NULL, NULL, vp->bs_beg.isub); ierr = bs && v_plot(vp, V_ALLNEW, 1, bs) < 0; break; case KEY_UT: /* Following cursor input selects UT range */ ierr = v_newut(vp); break; case KEY_ZOOM: /* Following cursor input selects amp/phase range */ ierr = v_zoom(vp); break; case KEY_CUT: /* Flag points within a select-box */ ierr = v_box(vp, 1); break; case KEY_REST: /* Restore points inside a select-box */ ierr = v_box(vp, 0); break; case KEY_NUMB: /* Change number of plots per page */ ierr = v_newnum(vp); break; case KEY_CUR: /* Toggle flag status of nearest point */ ierr = v_toggle(vp, vp->cursor.vs, vp->cursor.utval, vp->cursor.value, vp->cursor.wasamp); break; case KEY_ZAP: /* Zap all points of a given scan/baseline */ ierr = v_zap(vp, vp->cursor.vs, vp->cursor.sc, 1); break; case KEY_CROSS: vp->docross = !vp->docross; break; case KEY_ORDER: vp->doall = !vp->doall; if(v_plot(vp, V_RESET, 1, NULL) <= 0) vp->doall = !vp->doall; break; case KEY_HELP: /* Print usage info */ printf("Vplot key bindings:\n"); printf(" %c - List the following key bindings.\n", KEY_HELP); printf(" %c - Exit vplot (right-mouse-button).\n", KEY_QUIT); printf(" %c - Flag or un-flag the visibility nearest the cursor (left-mouse-button).\n", KEY_CUR); printf(" %c - Select a new time range (hit %c again for the full range).\n", KEY_UT, KEY_UT); printf(" %c - Select a new amplitude or phase range (hit %c twice for full range).\n", KEY_ZOOM, KEY_ZOOM); printf(" %c - Flag all data inside a specified rectangular box.\n", KEY_CUT); printf(" %c - Restore data inside a specified rectangular box.\n", KEY_REST); printf(" %c - Flag all visibilities of a selected baseline and scan.\n", KEY_ZAP); printf(" %c - Redisplay the current plot.\n", KEY_DIS); printf(" %c - Display the next set of baselines.\n", tolower(KEY_NXT)); printf(" %c - Display the preceding set of baselines.\n", tolower(KEY_PRV)); printf(" %c - Display the next sub-array.\n", KEY_NXT); printf(" %c - Display the preceding sub-array.\n", KEY_PRV); printf(" %c - Plot from the next IF.\n", KEY_NXTIF); printf(" %c - Plot from the preceding IF.\n", KEY_PRVIF); printf(" %c - Toggle whether to display model visibilities.\n", KEY_MOD); printf(" %c - Toggle whether to display flagged visibilities.\n", KEY_FLG); printf(" %c - Toggle whether to display error bars.\n", KEY_ERR); printf(" %c - Select the number of sub-plots per page.\n", KEY_NUMB); printf(" %c - Toggle between seeing all or just upper baselines.\n", KEY_ORDER); printf(" %c - Plot only amplitudes.\n", KEY_AMP); printf(" %c - Plot only phases.\n", KEY_PHS); printf(" %c - Plot both amplitudes and phases.\n", KEY_BOTH); printf(" %c - Toggle whether to break the plot into scans (where present).\n", KEY_BRK); printf(" %c - Toggle whether to use flagged data in autoscaling.\n", KEY_FUL); printf(" %c - Toggle whether to use a cross-hair cursor if available.\n", KEY_CROSS); printf(" %c - Request a new reference telescope/baseline.\n",KEY_TEL); printf(" %c - (SPACE BAR) Toggle station based vs. baseline based editing.\n", KEY_INT); printf(" %c - Toggle IF editing scope.\n", KEY_IF); printf(" %c - Toggle spectral-line channel editing scope.\n", KEY_CH); printf("\n"); break; case KEY_QUIT: finished = 1; break; default: break; }; }; }; } /* * Non-interactive plotting? */ else if(!ierr) { int page; /* * Plot as many pages as required, and keep the user informed. * Note that one page has already been plotted. */ for(page=1; !ierr && (npage<=0 || pagemodified; /* * Clean up. */ vp = del_Vedpar(vp); /* * Reinstate the original IF. */ if(set_cif_state(ob, old_if)) ierr = 1; return ierr; } /*....................................................................... * Toggle plotting flags given a command key. * * Input: * vp Vedpar * The plot descriptor. * key int The command key (upper case). * waslow int If true the key was lower case. * Output: * return int 0 - OK. * 1 - Key unrecognized. */ static int v_flags(Vedpar *vp, int key, int waslow) { switch (key) { case KEY_MOD: /* Toggle the display-model flag */ vp->domod = !vp->domod; break; case KEY_FLG: /* Toggle the display-flagged-data flag */ vp->doflag = !vp->doflag; break; case KEY_ERR: vp->dobars = !vp->dobars; break; case KEY_FUL: /* Toggle full - restricted plot */ vp->showall = !vp->showall; break; case KEY_AMP: vp->doamp = 1; vp->dophs = 0; break; case KEY_PHS: vp->doamp = 0; vp->dophs = 1; break; case KEY_BOTH: vp->doamp = vp->dophs = 1; break; case KEY_BRK: vp->doscan = !vp->doscan; break; default: return 1; }; return 0; }