IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40659 for trunk


Ignore:
Timestamp:
Mar 29, 2019, 4:23:48 PM (7 years ago)
Author:
eugene
Message:

fix some fitting details (slit tilt interpolation)

Location:
trunk/Ohana/src/opihi/mana
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/mana/deimos_fitslit.c

    r40622 r40659  
    3232  int Ny = wind[0].matrix.Naxis[1];
    3333 
    34   if (Nx != slit[0].matrix.Naxis[0]) return FALSE;
    35   if (Ny != slit[0].matrix.Naxis[1]) return FALSE;
     34  if (Nx != slit[0].matrix.Naxis[0]) { gprint (GP_ERR, "size mismatch in fitslit for window and slit\n"); return FALSE; }
     35  if (Ny != slit[0].matrix.Naxis[1]) { gprint (GP_ERR, "size mismatch in fitslit for window and slit\n"); return FALSE; }
    3636
    3737  ResetVector (flux, OPIHI_FLT, Ny);
  • trunk/Ohana/src/opihi/mana/deimos_getobj.c

    r40642 r40659  
    6363
    6464  float stilt = 0.0; // angle of the slit
     65
     66  int SaveSegments = FALSE;
     67  if ((N = get_argument (argc, argv, "-save-segments"))) {
     68    remove_argument (N, &argc, argv);
     69    SaveSegments = TRUE;
     70  }
    6571
    6672  // Input parameters:
     
    194200  float dxMax = 0; // maximum distance between sky regions
    195201
     202  Vector *skyLsV = NULL, *skyLeV = NULL, *skyLfV = NULL, *skyRsV = NULL, *skyReV = NULL, *skyRfV = NULL;
     203  Vector *bckLsV = NULL, *bckLeV = NULL, *bckLfV = NULL, *bckRsV = NULL, *bckReV = NULL, *bckRfV = NULL;
     204  if (SaveSegments) {
     205    skyLsV = SelectVector ("skyLs", ANYVECTOR, TRUE);  ResetVector (skyLsV, OPIHI_FLT, Ny);
     206    skyLeV = SelectVector ("skyLe", ANYVECTOR, TRUE);  ResetVector (skyLeV, OPIHI_FLT, Ny);
     207    skyLfV = SelectVector ("skyLf", ANYVECTOR, TRUE);  ResetVector (skyLfV, OPIHI_FLT, Ny);
     208    skyRsV = SelectVector ("skyRs", ANYVECTOR, TRUE);  ResetVector (skyRsV, OPIHI_FLT, Ny);
     209    skyReV = SelectVector ("skyRe", ANYVECTOR, TRUE);  ResetVector (skyReV, OPIHI_FLT, Ny);
     210    skyRfV = SelectVector ("skyRf", ANYVECTOR, TRUE);  ResetVector (skyRfV, OPIHI_FLT, Ny);
     211    bckLsV = SelectVector ("bckLs", ANYVECTOR, TRUE);  ResetVector (bckLsV, OPIHI_FLT, Ny);
     212    bckLeV = SelectVector ("bckLe", ANYVECTOR, TRUE);  ResetVector (bckLeV, OPIHI_FLT, Ny);
     213    bckLfV = SelectVector ("bckLf", ANYVECTOR, TRUE);  ResetVector (bckLfV, OPIHI_FLT, Ny);
     214    bckRsV = SelectVector ("bckRs", ANYVECTOR, TRUE);  ResetVector (bckRsV, OPIHI_FLT, Ny);
     215    bckReV = SelectVector ("bckRe", ANYVECTOR, TRUE);  ResetVector (bckReV, OPIHI_FLT, Ny);
     216    bckRfV = SelectVector ("bckRf", ANYVECTOR, TRUE);  ResetVector (bckRfV, OPIHI_FLT, Ny);
     217  }
     218
    196219  // loop over the y positions
    197220  for (int iy = 0; iy < Ny; iy++) {
     
    211234    dxMax = MAX (dxMax, skyX_rt[iy] - skyX_lf[iy]); // this is a constant value unless we ignore some of the pixels
    212235    // assert skyX_rt > skyX_lf ?
     236
     237    if (SaveSegments) {
     238      skyLsV->elements.Flt[iy] = S_s_l + Xtrace;
     239      skyLeV->elements.Flt[iy] = S_e_l + Xtrace;
     240      skyLfV->elements.Flt[iy] = skyF_lf[iy];
     241      skyRsV->elements.Flt[iy] = S_s_r + Xtrace;
     242      skyReV->elements.Flt[iy] = S_e_r + Xtrace;
     243      skyRfV->elements.Flt[iy] = skyF_rt[iy];
     244      bckLsV->elements.Flt[iy] = B_s_l + Xtrace;
     245      bckLeV->elements.Flt[iy] = B_e_l + Xtrace;
     246      bckLfV->elements.Flt[iy] = bckF_lf[iy];
     247      bckRsV->elements.Flt[iy] = B_s_r + Xtrace;
     248      bckReV->elements.Flt[iy] = B_e_r + Xtrace;
     249      bckRfV->elements.Flt[iy] = bckF_rt[iy];
     250    }
    213251  }
    214252
     
    253291    float Xtrace = Xref - Xpsf + dXtrace;
    254292   
     293    // include the PSF trace and restrict the fit below to portions where the profile is > 0.95
     294
    255295    // now I need to find the limits of the PSF in the buffer at this iy location
    256296    for (int ipsf = 0; ipsf < Npsf; ipsf ++) {
     
    267307    float S1 = 0.0, S2 = 0.0;
    268308    for (int ipsf = 0; ipsf < Npsf; ipsf++) {
     309      if (iy == 6000) {
     310        fprintf (stderr, "%d : %f %f : %f\n", ipsf, tmpv[ipsf], psfV[ipsf], tmpv[ipsf]*psfV[ipsf]);
     311      }
    269312      S1 += tmpv[ipsf]*psfV[ipsf]; // if we have an errorbar, include / SQ(sigv[i])
    270313      S2 += psfV[ipsf]*psfV[ipsf]; // if we have an errorbar, include / SQ(sigv[i])
  • trunk/Ohana/src/opihi/mana/deimos_mkmodel.c

    r40655 r40659  
    164164        opihi_flt g = 0.0, s = 0.0;
    165165        for (int n = -Nkernel_y2; n <= Nkernel_y2; n++) {
    166           if (iy + n < 0) continue; // bottom edge of full image
    167           if (iy + n >= Ny) continue; // top edge of full image
     166          if (iy - n < 0) continue; // bottom edge of full image
     167          if (iy - n >= Ny) continue; // top edge of full image
    168168          int pix = ix + (n + Nkernel_y2)*Nx;
    169169          myAssert (pix < Nkernel_pix, "oops (apply_tilt)");
    170           s += kernel[pix]*input[ix + (iy + n)*Nx];
     170          s += kernel[pix]*input[ix + (iy - n)*Nx];
    171171          g += kernel[pix]; // optimization: save g[ix], all should be the same
    172172        }
  • trunk/Ohana/src/opihi/mana/deimos_mkobj.c

    r40655 r40659  
    208208
    209209  float sin_stilt = sin(stilt*RAD_DEG);
    210   int Nyk = ceil(Nx * fabs(sin_stilt));
     210  int Nyk = ceil(Nx * fabs(sin_stilt)) + 1; // one extra pixel buffer
    211211  if (Nyk < 3) Nyk = 3; // minimum of 3 pixels (or kernel assumption below fails)
    212212  Nyk += NlsfFull;
     
    260260      myAssert (Nkpix_i < Nkpix, "oops");
    261261      kernel[Nkpix_i] = dyf;
    262       // fprintf (stderr, "%d, %d: %f %f\n", ix, (dyi + Nyk2), kernel[ix + (dyi + Nyk2 + 0)*Nx], kernel[ix + (dyi + Nyk2 + 1)*Nx]);
     262      fprintf (stderr, "%d, %d: %f %f\n", ix, (dyi + Nyk2), kernel[ix + (dyi + Nyk2 + 0)*Nx], kernel[ix + (dyi + Nyk2 + 1)*Nx]);
    263263    }
    264264  }
     
    280280        opihi_flt g = 0.0, s = 0.0;
    281281        for (int n = -Nyk2; n <= Nyk2; n++) {
    282           if (iy + n < 0) continue; // bottom edge of full image
    283           if (iy + n >= Ny) continue; // top edge of full image
     282          if (iy - n < 0) continue; // bottom edge of full image
     283          if (iy - n >= Ny) continue; // top edge of full image
    284284          int Nkpix_i = ix + (n + Nyk2)*Nx;
    285285          myAssert (Nkpix_i < Nkpix, "oops");
    286           s += kernel[Nkpix_i]*s1[ix + (iy + n)*Nx];
     286          s += kernel[Nkpix_i]*s1[ix + (iy - n)*Nx];
    287287          g += kernel[Nkpix_i];
    288288        }
  • trunk/Ohana/src/opihi/mana/deimos_mkslit.c

    r40622 r40659  
    5656
    5757  // define the output window
    58   int Nx = 2*profile[0].Nelements;
     58  int Nx = 2*profile[0].Nelements + 1;
    5959  int Ny = flux ? flux[0].Nelements : fluxbins;
    6060 
Note: See TracChangeset for help on using the changeset viewer.