Changeset 2909


Ignore:
Timestamp:
03/24/14 17:32:50 (10 years ago)
Author:
WataruKawasaki
Message:

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs:

Put in Release Notes:

Module(s): sd

Description: (1) a bug fix in sd.scantable.parse_spw_selection(). modified to get rest frequency value correctly based on molecule ID stored for each spw (the first spectrum having the specified spw in scantable). (2) renamed 'annotation' to 'text' in class or variable names for sd.plotter2.


Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/plotter2.py

    r2896 r2909  
    545545    def set_arrow(self, xtail, xhead, ytail, yhead, color=None, width=None, linestyle=None, headsize=None, headfs=None, headangle=None, headvent=None, vpid=None, arrowid=None):
    546546        """\
    547         append an arrow or change existing arrow attributes.
     547        draw an arrow or change existing arrow attributes.
    548548
    549549        Parameters:
     
    589589        self._plotter.set_arrow(xtail, xhead, ytail, yhead, coloridx, width, linestyleidx, headsize, headfsidx, headangle, headvent, vpid, arrowid)
    590590
    591     def set_annotation(self, label, posx=None, posy=None, angle=None, fjust=None, size=None, style=None, color=None, bgcolor=None, vpid=None, annid=None):
    592         if posx    is None: posx    = 0.5
    593         if posy    is None: posy    = 0.5
     591    def set_text(self, text, posx=None, posy=None, angle=None, fjust=None, size=None, style=None, color=None, bgcolor=None, vpid=None, textid=None):
     592        """\
     593        write text string or change existing text attributes.
     594       
     595        Parameters:
     596            text:    text string.
     597            posx:    x position of text in world coordinate.
     598                     default is center of x axis.
     599            posy:    y position of text in world coordinate.
     600                     default is center of y axis.
     601            angle:   rotation angle of text in unit of degree.
     602                     0.0 (default) is horizontal.
     603            fjust:   horizontal justification of text string. if 0.0
     604                     (default) is given, the text is left-justified at
     605                     (posx, posy). if 0.5, the text is centered, and if
     606                     1.0, the text is right-justified.
     607            size:    size of text string. the default is 1.0.
     608            style:   font style. "normal", "roman", "italic" and "script"
     609                     are available. default is "normal".
     610            color:   color of text. see output of list_colornames().
     611                     default is "black".
     612            bgcolor: background color of text. see output of
     613                     list_colornames(). default is transparent(-1).
     614            vpid:    viewport id. when not given, the last viewport will
     615                     be the target.
     616            textid:  text id independently defined for each viewport.
     617                     when not given, the text having the final text id
     618                     for the specified viewport will be the target.
     619        """
     620        if posx    is None: posx    = -1.0
     621        if posy    is None: posy    = -1.0
    594622        if angle   is None: angle   = 0.0
    595         if fjust   is None: fjust   = 0.5
     623        if fjust   is None: fjust   = 0.0
    596624        if size    is None: size    = 1.0
    597625        if style   is None: style   = ""
     
    599627        if bgcolor is None: bgcolor = "" # transparent
    600628        if vpid    is None: vpid    = -1
    601         if annid   is None: annid   = -1
     629        if textid  is None: textid  = -1
    602630       
    603631        coloridx = self.get_colorindex(color)
    604         bgcoloridx = self.get_colorindex(bgcolor) if (bgcolor.strip() != "") else bgcolor
    605        
    606         self._plotter.set_annotation(label, posx, posy, angle, fjust, size, style, coloridx, bgcoloridx, vpid, annid)
     632        bgcoloridx = self.get_colorindex(bgcolor) if (bgcolor.strip() != "") else -1 #bgcolor
     633       
     634        self._plotter.set_text(text, posx, posy, angle, fjust, size, style, coloridx, bgcoloridx, vpid, textid)
    607635
    608636    def set_xlabel(self, label, style=None, size=None, posx=None, posy=None, vpid=None):
     
    620648            posx:  x position of label string in window coordinate.
    621649                   default is the center of x axis.
    622             posy:  y position of label string.
     650            posy:  y position of label string in window coordinate.
    623651            vpid:  viewport id. when not given, the last viewport
    624652                   will be the target.
     
    645673                   of number labels)
    646674            posx:  x position of label string in window coordinate.
    647             posy:  y position of label string.
     675            posy:  y position of label string in window coordinate.
    648676                   default is the center of y axis.
    649677            vpid:   viewport id. when not given, the last viewport
  • trunk/python/scantable.py

    r2902 r2909  
    20532053                pmin = 0.0
    20542054                pmax = float(self.nchan(spw) - 1)
     2055
     2056                molid = self._getmolidcol_list()[self.get_first_rowno_by_if(spw)]
    20552057               
    20562058                if (len(colon_sep) == 1):
     
    21102112                                elif is_number(expr0) and is_velocity(expr1):
    21112113                                    # 'a~b*m/s'
    2112                                     restf = self.get_restfreqs().values()[0][0]
     2114                                    restf = self.get_restfreqs()[molid][0]
    21132115                                    (expr_v0, expr_v1) = get_velocity_by_string(expr0, expr1)
    21142116                                    dppl = self.get_doppler()
  • trunk/src/Plotter2.cpp

    r2896 r2909  
    33namespace asap {
    44
    5 Plotter2AnnotationInfo::Plotter2AnnotationInfo() {
     5Plotter2TextInfo::Plotter2TextInfo() {
    66    text = "";
    77    posx = 0.0;
     
    1414}
    1515
    16 Plotter2AnnotationInfo::~Plotter2AnnotationInfo() {
     16Plotter2TextInfo::~Plotter2TextInfo() {
    1717}
    1818
     
    103103    vRect.clear();
    104104    vArro.clear();
    105     vAnno.clear();
     105    vText.clear();
    106106
    107107    labelXString = "";
     
    139139    vRect.clear();
    140140    vArro.clear();
    141     vAnno.clear();
     141    vText.clear();
    142142}
    143143
     
    917917    di->lineWidth = width;
    918918    di->lineStyle = style;
    919     //vi->vData[dataid].lineStyle = style;
    920919}
    921920
     
    11331132}
    11341133
    1135 void Plotter2::setAnnotation(const std::string& label, const float posx, const float posy, const float angle, const float fjust, const float size, const std::string& style, const int color, const int bgcolor, const int inVpid, const int inAnnid) {
    1136     int vpid = inVpid;
    1137     if (vpid >= (int)vInfo.size()) {
    1138         exit(0);
    1139     }
    1140     if (vpid < 0) {
    1141         vpid = vInfo.size() - 1;
    1142     }
    1143     if (vpid < 0) {
    1144         Plotter2ViewportInfo vi;
    1145         vInfo.push_back(vi);
    1146         vpid = 0;
    1147     }
    1148 
    1149     Plotter2ViewportInfo* vi = &vInfo[vpid];
    1150 
    1151     int annotationid = inAnnid;
     1134void Plotter2::setText(const std::string& text, const float inPosx, const float inPosy, const float angle, const float fjust, const float size, const std::string& style, const int color, const int bgcolor, const int inVpid, const int inTextid) {
     1135    int vpid = inVpid;
     1136    if (vpid >= (int)vInfo.size()) {
     1137        exit(0);
     1138    }
     1139    if (vpid < 0) {
     1140        vpid = vInfo.size() - 1;
     1141    }
     1142    if (vpid < 0) {
     1143        Plotter2ViewportInfo vi;
     1144        vInfo.push_back(vi);
     1145        vpid = 0;
     1146    }
     1147
     1148    Plotter2ViewportInfo* vi = &vInfo[vpid];
     1149
     1150    int annotationid = inTextid;
    11521151    if (annotationid < 0) {
    1153         Plotter2AnnotationInfo ai;
    1154         vi->vAnno.push_back(ai);
    1155         annotationid = vi->vAnno.size() - 1;
    1156     } else if (annotationid >= (int)vi->vAnno.size()) {
    1157         exit(0);
    1158     }
    1159 
    1160     Plotter2AnnotationInfo* ai = &vi->vAnno[annotationid];
     1152        Plotter2TextInfo ti;
     1153        vi->vText.push_back(ti);
     1154        annotationid = vi->vText.size() - 1;
     1155    } else if (annotationid >= (int)vi->vText.size()) {
     1156        exit(0);
     1157    }
     1158
     1159    Plotter2TextInfo* ti = &vi->vText[annotationid];
    11611160
    11621161    std::string styleString;
     
    11711170    }
    11721171
    1173     ai->text = styleString + label;
    1174     ai->posx = posx;
    1175     ai->posy = posy;
    1176     ai->angle = angle;
    1177     ai->fjust = fjust;
    1178     ai->size = size;
    1179     ai->color = color;
    1180     ai->bgcolor = bgcolor;
     1172    ti->text = styleString + text;
     1173
     1174    float posx = inPosx;
     1175    if (posx < 0.0) {
     1176        posx = 0.5*(vi->vpPosXMin + vi->vpPosXMax);
     1177    }
     1178    ti->posx = posx;
     1179
     1180    float posy = inPosy;
     1181    if (posy < 0.0) {
     1182        posy = 0.5*(vi->vpPosYMin + vi->vpPosYMax);
     1183    }
     1184    ti->posy = posy;
     1185
     1186    ti->angle = angle;
     1187    ti->fjust = fjust;
     1188    ti->size = size;
     1189    ti->color = color;
     1190    ti->bgcolor = bgcolor;
    11811191}
    11821192
     
    14581468            }
    14591469
    1460             // annotations
    1461             for (unsigned int j = 0; j < vi.vAnno.size(); ++j) {
     1470            // arbitrary texts
     1471            for (unsigned int j = 0; j < vi.vText.size(); ++j) {
    14621472                resetAttributes(vi);
    14631473
    1464                 Plotter2AnnotationInfo ai = vi.vAnno[j];
    1465                 cpgsch(ai.size);
    1466                 cpgsci(ai.color);
    1467                 cpgstbg(ai.bgcolor);
    1468                 cpgptxt(ai.posx, ai.posy, ai.angle, ai.fjust, ai.text.c_str());
     1474                Plotter2TextInfo ti = vi.vText[j];
     1475                cpgsch(ti.size);
     1476                cpgsci(ti.color);
     1477                cpgstbg(ti.bgcolor);
     1478                cpgptxt(ti.posx, ti.posy, ti.angle, ti.fjust, ti.text.c_str());
    14691479            }
    14701480
  • trunk/src/Plotter2.h

    r2896 r2909  
    1111namespace asap {
    1212
    13 class Plotter2AnnotationInfo {
    14 public:
    15     Plotter2AnnotationInfo();
    16     ~Plotter2AnnotationInfo();
     13class Plotter2TextInfo {
     14public:
     15    Plotter2TextInfo();
     16    ~Plotter2TextInfo();
    1717
    1818    std::string text;
     
    140140
    141141    //annotations
    142     std::vector<Plotter2AnnotationInfo> vAnno;
     142    std::vector<Plotter2TextInfo> vText;
    143143
    144144    // x-label
     
    239239    void setMaskX(const float xmin, const float xmax, const int color, const int fill, const int width, const float hsep, const int inVpid);
    240240    void setArrow(const float xtail, const float xhead, const float ytail, const float yhead, const int color, const int width, const int lineStyle, const float headSize, const int headFillStyle, const float headAngle, const float headVent, const int inVpid, const int inArrowid);
    241     void setAnnotation(const std::string& label, const float posx, const float posy, const float angle, const float fjust, const float size, const std::string& style, const int color, const int bgcolor, const int inVpid, const int inAnnid);
    242     void setLabelX(const std::string& label, const float posx, const float posy, const float size, const std::string& style, const int color, const int bgcolor, const int inVpid);
    243     void setLabelY(const std::string& label, const float posx, const float posy, const float size, const std::string& style, const int color, const int bgcolor, const int inVpid);
    244     void setTitle(const std::string& label, const float posx, const float posy, const float size, const std::string& style, const int color, const int bgcolor, const int inVpid);
     241    void setText(const std::string& text, const float inPosx, const float inPosy, const float angle, const float fjust, const float size, const std::string& style, const int color, const int bgcolor, const int inVpid, const int inTextid);
     242    void setLabelX(const std::string& label, const float inPosx, const float inPosy, const float size, const std::string& style, const int color, const int bgcolor, const int inVpid);
     243    void setLabelY(const std::string& label, const float inPosx, const float inPosy, const float size, const std::string& style, const int color, const int bgcolor, const int inVpid);
     244    void setTitle(const std::string& label, const float inPosx, const float inPosy, const float size, const std::string& style, const int color, const int bgcolor, const int inVpid);
    245245    void setViewportBackgroundColor(const int bgcolor, const int inVpid);
    246246    void plot();
  • trunk/src/python_Plotter2.cpp

    r2896 r2909  
    8282         .def("set_mask_x",&Plotter2::setMaskX)
    8383         .def("set_arrow",&Plotter2::setArrow)
    84          .def("set_annotation",&Plotter2::setAnnotation)
     84         .def("set_text",&Plotter2::setText)
    8585         .def("set_label_x",&Plotter2::setLabelX)
    8686         .def("set_label_y",&Plotter2::setLabelY)
Note: See TracChangeset for help on using the changeset viewer.