Changeset 2718


Ignore:
Timestamp:
01/09/13 14:27:57 (11 years ago)
Author:
Kana Sugimoto
Message:

New Development: No (a bug fix)

JIRA Issue: No

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs:

Put in Release Notes: No

Module(s): asapplotter and sdplot

Description:

fixed a bug in increment.
better log messages.


Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/asapplotter.py

    r2717 r2718  
    18371837            asaplog.post("WARN")
    18381838
    1839 #         # Center and spacing
    1840 #         dirarr = array(self._data.get_directionval()).transpose()
    1841 #         print "Pointing range: (x, y) = (%f - %f, %f - %f)" %\
    1842 #               (dirarr[0].min(),dirarr[0].max(),dirarr[1].min(),dirarr[1].max())
    1843 #         dircent = [0.5*(dirarr[0].max() + dirarr[0].min()),
    1844 #                    0.5*(dirarr[1].max() + dirarr[1].min())]
    1845 #         del dirarr
    1846 #         if center is None:
    1847 #             #asaplog.post()
    1848 #             asaplog.push("Grid center is not specified. Automatically calculated from pointing center.")
    1849 #             #asaplog.post("WARN")
    1850 #             #center = [dirarr[0].mean(), dirarr[1].mean()]
    1851 #             center = dircent
    1852 #         elif (type(center) in (list, tuple)) and len(center) > 1:
    1853 #             from numpy import pi
    1854 #             # make sure center_x is in +-pi of pointing center
    1855 #             # (assumes dirs are in rad)
    1856 #             rotnum = round(abs(center[0] - dircent[0])/(2*pi))
    1857 #             if center[0] < dircent[0]: rotnum *= -1
    1858 #             cenx = center[0] - rotnum*2*pi
    1859 #             center = [cenx, center[1]]
    1860 #         else:
    1861 #             msg = "Direction of grid center should be a list of float (R.A., Dec.)"
    1862 #             raise ValueError, msg
    1863 #         asaplog.push("Grid center: (%f, %f) " % (center[0],center[1]))
    1864 
    1865 #         if spacing is None:
    1866 #             #asaplog.post()
    1867 #             asaplog.push("Grid spacing not specified. Automatically calculated from map coverage")
    1868 #             #asaplog.post("WARN")
    1869 #             # automatically get spacing
    1870 #             dirarr = array(self._data.get_directionval()).transpose()
    1871 #             wx = 2. * max(abs(dirarr[0].max()-center[0]),
    1872 #                           abs(dirarr[0].min()-center[0]))
    1873 #             wy = 2. * max(abs(dirarr[1].max()-center[1]),
    1874 #                           abs(dirarr[1].min()-center[1]))
    1875 #             ## slightly expand area to plot the edges
    1876 #             #wx *= 1.1
    1877 #             #wy *= 1.1
    1878 #             xgrid = wx/max(self._cols-1.,1.)
    1879 #             #xgrid = wx/float(max(self._cols,1.))
    1880 #             xgrid *= cos(center[1])
    1881 #             ygrid = wy/max(self._rows-1.,1.)
    1882 #             #ygrid = wy/float(max(self._rows,1.))
    1883 #             # single pointing (identical R.A. and/or Dec. for all spectra.)
    1884 #             if xgrid == 0:
    1885 #                 xgrid = 1.
    1886 #             if ygrid == 0:
    1887 #                 ygrid = 1.
    1888 #             # spacing should be negative to transpose plot
    1889 #             spacing = [- xgrid, - ygrid]
    1890 #             del dirarr, xgrid, ygrid
    1891 #         #elif isinstance(spacing, str):
    1892 #         #    # spacing is a quantity
    1893 #         elif (type(spacing) in (list, tuple)) and len(spacing) > 1:
    1894 #             for i in xrange(2):
    1895 #                 val = spacing[i]
    1896 #                 if not isinstance(val, float):
    1897 #                     raise TypeError("spacing should be a list of float")
    1898 #                 if val > 0.:
    1899 #                     spacing[i] = -val
    1900 #             spacing = spacing[0:2]
    1901 #         else:
    1902 #             msg = "Invalid spacing."
    1903 #             raise TypeError(msg)
    1904 #         asaplog.push("Spacing: (%f, %f) (projected)" % (spacing[0],spacing[1]))
    1905 
    19061839        # Prepare plotter
    19071840        self._assert_plotter(action="reload")
  • trunk/src/PlotHelper.cpp

    r2717 r2718  
    7474{
    7575  LogIO os(LogOrigin("PlotHelper","getSTCoord()", WHERE));
    76   os << "Start getSTCoord()" << LogIO::POST;
     76  os << "Getting pointing information of the scantable." << LogIO::POST;
    7777  if (data_p->nrow() < 1)
    7878    throw AipsError("Scantable is not set. Please set a scantable first.");
     
    107107#ifdef KS_DEBUG
    108108  {//Debug outputs
    109     cout << "Generating a coordinate from DIRECTIONs in a scantable: " << endl;
     109    cout << "Generated a temporal direction coordinate of a scantable: " << endl;
    110110    Vector<String> units = coord.worldAxisUnits();
    111111    Vector<Double> refv = coord.referenceValue();
     
    126126{
    127127  LogIO os(LogOrigin("PlotHelper","setGridParam()", WHERE));
    128   os << "Start setGridParam()" << LogIO::POST;
    129128  // Value check of nx and ny
    130129  if (nx < 1)
     
    193192  }
    194193
     194  os << "Setting grid parameters" << LogIO::POST;
    195195  // Now, define direction coordinate from input parameters (in radian)
    196196  Double incx, incy;
     
    199199  // center
    200200  if (center.empty()){
     201    os << "center is not specified. Using pointing center of the scantable." << LogIO::POST;
    201202    if (!stset)
    202203      throw AipsError("Scantable is not set. Could not resolve map center.");
    203 #ifdef KS_DEBUG
    204     cout << "Using pointing center from DIRECTION column" << endl;
    205 #endif
     204
    206205    centx = stcent.getAngle("rad").getValue()[0];
    207206    centy = stcent.getAngle("rad").getValue()[1];
    208207    mdt = stdt;
    209208  } else {
    210 #ifdef KS_DEBUG
    211     cout << "Using user defined grid center" << endl;
    212 #endif
     209    os << "Using user defined center" << LogIO::POST;
    213210    // Parse center string
    214211    string::size_type pos0 = center.find(" ");
     
    230227    if (!MDirection::getType(mdt,sepoch))
    231228      throw AipsError("Invalid direction reference in center");
    232     if (stset && mdt != stdt)
     229    if (stset && (mdt != stdt))
    233230      throw AipsError("Direction reference of center should be the same as input scantable");
    234231    QuantumHolder qh ;
     
    248245    }
    249246  }
    250 #ifdef KS_DEBUG
    251   cout << "The center direction of plotting grids: [" << centx  << ", " << centy << "] (rad)" <<endl;
    252 #endif
     247  os << "Grid center: ( "  << centx  << " rad , " << centy << " rad ) " << LogIO::POST;
    253248
    254249  // cell
    255250  if (cellx.empty() && celly.empty()){
     251    os << "cell size is not specified. Using cell size to cover all pointings in the scantable." << LogIO::POST;
    256252    if (!stset)
    257253      throw AipsError("Scantable is not set. Could not resolve cell size.");
    258 #ifdef KS_DEBUG
    259     cout << "Using cell size defined from DIRECTION column" << endl;
    260 #endif
     254
    261255    Vector<Double> centpix;
    262256    MDirection centmd = MDirection(Quantum<Double>(centx, "rad"),
     
    273267    incy = wy / max(ny - 1., 1.);
    274268  } else {
    275 #ifdef KS_DEBUG
    276     cout << "Using user defined cell size" << endl;
    277 #endif
     269    os << "Using user defined cell size" << LogIO::POST;
    278270    Quantum<Double> qcellx, qcelly;
    279271    if (!cellx.empty() && !celly.empty()){
     
    290282    incy = qcelly.getValue("rad");
    291283  }
    292 #ifdef KS_DEBUG
    293   cout << "The cell size of plotting grids: [" << incx << ", " << incy << "] (rad)" <<endl;
    294 #endif
     284  // inc should be negative to transpose plot
     285  incx = -abs(incx);
     286  incy = -abs(incy);
     287
     288  os << "Spacing: ( " << abs(incx) << " rad , " << abs(incy) << " rad )" <<endl;
    295289
    296290  Matrix<Double> xform(2,2) ;
     
    302296                                      0.5*Double(nx),
    303297                                      0.5*Double(ny)) ; // pixel at center
    304   os << "Successfully finished generation of Direction Coordinate" << LogIO::POST;
     298  {//Summary
     299    os << "Successfully generated grid coordinate:" << LogIO::POST;
     300    Vector<String> units = dircoord_->worldAxisUnits();
     301    Vector<Double> refv = dircoord_->referenceValue();
     302    os <<"- Reference Direction : " << MDirection::showType(dircoord_->directionType())
     303       << " " << refv[0] << units[0] << " " << refv[1] << units[1]  << LogIO::POST;
     304    Vector<Double> refpix = dircoord_->referencePixel();
     305    os <<"- Reference Pixel     : [" << refpix[0] << ", " << refpix[1] << "]" << LogIO::POST;
     306    Vector<Double> inc = dircoord_->increment();
     307    os <<"- Increments          : [" << inc[0] << ", " << inc[1] << "]" << LogIO::POST;
     308    os <<"- Projection Type     : " << dircoord_->projection().name() << LogIO::POST;
     309  }
    305310};
    306311
     
    309314                                 const double centx, const double centy,
    310315                                 const string epoch, const string projname){
     316  LogIO os(LogOrigin("PlotHelper","setGridParamVal()", WHERE));
    311317  // Value check of nx and ny
    312318  if (nx < 1)
     
    343349//                                    0.5*Double(nx-1),
    344350//                                    0.5*Double(ny-1)) ; // pixel at grid
    345 #ifdef KS_DEBUG
    346   {//Debug outputs
    347   cout << "Direction coordinate is set: " << endl;
    348   Vector<String> units = dircoord_->worldAxisUnits();
    349   Vector<Double> refv = dircoord_->referenceValue();
    350   cout <<"Reference: " << MDirection::showType(dircoord_->directionType()) << " " << refv[0] << units[0] << " " << refv[1] << units[1]  << endl;
    351   Vector<Double> refpix = dircoord_->referencePixel();
    352   cout <<"Reference Pixel: [" << refpix[0] << ", " << refpix[1] << "]" << endl;
    353   Vector<Double> inc = dircoord_->increment();
    354   cout <<"Increments: [" << inc[0] << ", " << inc[1] << "]" << endl;
    355   cout <<"Projection: " << dircoord_->projection().name() << endl;
    356   }
    357 #endif
     351  {//Summary
     352    os << "Successfully generated grid coordinate:" << LogIO::POST;
     353    Vector<String> units = dircoord_->worldAxisUnits();
     354    Vector<Double> refv = dircoord_->referenceValue();
     355    os <<"- Reference Direction : " << MDirection::showType(dircoord_->directionType())
     356       << " " << refv[0] << units[0] << " " << refv[1] << units[1]  << LogIO::POST;
     357    Vector<Double> refpix = dircoord_->referencePixel();
     358    os <<"- Reference Pixel     : [" << refpix[0] << ", " << refpix[1] << "]" << LogIO::POST;
     359    Vector<Double> inc = dircoord_->increment();
     360    os <<"- Increments          : [" << inc[0] << ", " << inc[1] << "]" << LogIO::POST;
     361    os <<"- Projection Type     : " << dircoord_->projection().name() << LogIO::POST;
     362  }
    358363};
    359364
Note: See TracChangeset for help on using the changeset viewer.