include # rdprint -- print a pair of reseau entries # This task reads a pair of reseau entries and prints the reference positions # and the differences between the positions. The output may be piped to the # fieldplot task. For each reseau position, the four values printed to the # standard output are: # reference X, reference Y, distorted X - ref X, distorted Y - ref Y. # # Phil Hodge, 26-Dec-1989 Task created # Phil Hodge, 13-Sep-1993 Swap the order of the parameters. procedure rdprint() char inres1[SZ_FNAME] # name of reseau table for reference entry char inres2[SZ_FNAME] # name of reseau table for distorted entry char rentry[SZ_FNAME] # name of reference entry char dentry[SZ_FNAME] # name of entry for distorted positions #-- pointer rp1, rp2 # pointers to reseau tables pointer r_respt, d_respt # reseau entry pointer, reference & distorted real r_x, r_y # reference photocathode coords (pixels) real d_x, d_y # distorted photocathode coords (pixels) int nres # total number of reseau marks in entry int reseau # loop index for reseau number bool one_table # both entries from same table? int rs_readr() begin call clgstr ("inres1", inres1, SZ_FNAME) call clgstr ("entry", dentry, SZ_FNAME) call clgstr ("inres2", inres2, SZ_FNAME) call clgstr ("reference", rentry, SZ_FNAME) # Open reseau tables. call dpr_open (inres1, inres2, rp1, rp2, one_table) # Allocate space for the distorted entry and read it. call rs_alloc (rp1, TY_REAL, d_respt) if (rs_readr (rp1, d_respt, dentry, 0) == RES_F_NONEXTENTRY) call error (1, "distorted entry not found") # Now the reference entry. call rs_alloc (rp2, TY_REAL, r_respt) if (rs_readr (rp2, r_respt, rentry, 0) == RES_F_NONEXTENTRY) call error (1, "reference entry not found") if (RES_NCOLS(rp1) != RES_NCOLS(rp2) || RES_NROWS(rp1) != RES_NROWS(rp2)) call error (1, "size of reseau entries must be the same") # Print them. nres = RES_NCOLS(rp1) * RES_NROWS(rp1) do reseau = 0, nres-1 { if ( ! (Memb[RES_FPT(d_respt)+reseau] || Memb[RES_FPT(r_respt)+reseau]) ) { dx = Memr[RES_XPT(d_respt)+reseau] dy = Memr[RES_YPT(d_respt)+reseau] rx = Memr[RES_XPT(r_respt)+reseau] ry = Memr[RES_YPT(r_respt)+reseau] call printf ("%15.7g %15.7g %15.7g %15.7g\n") call pargr (rx) call pargr (ry) call pargr (dx - rx) call pargr (dy - ry) } } if ( ! one_table ) call rs_close (rp2) call rs_close (rp1) end # dpr_open -- open reseau tables # This routine opens the two input reseau tables. procedure dpr_open (inres1, inres2, rp1, rp2, one_table) char inres1[ARB] # i: name of reseau table with distorted positions char inres2[ARB] # io: reference reseau table (leading blanks removed) pointer rp1 # o: pointer to struct for inres1 pointer rp2 # o: pointer to struct for inres2; this will be the # same as rp1 if one_table is true bool one_table # o: true if inres2 is same as inres1 #-- pointer rs_open() bool streq() begin # Remove leading blanks in case inres2 is blank when the user # intended it to be null. call xt_stripwhite (inres2) if (inres2[1] == EOS || streq (inres1, inres2)) { # Get both from the same input table. one_table = true rp1 = rs_open (inres1, READ_ONLY, NULL) rp2 = rp1 } else { # Separate tables. one_table = false rp1 = rs_open (inres1, READ_ONLY, NULL) rp2 = rs_open (inres2, READ_ONLY, NULL) } end