wiki:TracQuery

Version 2 (modified by trac, 12 years ago) ( diff )

--

Trac Ticket Queries

In addition to reports, Trac provides support for custom ticket queries, used to display lists of tickets meeting a specified set of criteria.

To configure and execute a custom query, switch to the View Tickets module from the navigation bar, and select the Custom Query link.

Filters

When you first go to the query page the default filter will display tickets relevant to you:

  • If logged in then all open tickets it will display open tickets assigned to you.
  • If not logged in but you have specified a name or email address in the preferences then it will display all open tickets where your email (or name if email not defined) is in the CC list.
  • If not logged and no name/email defined in the preferences then all open issues are displayed.

Current filters can be removed by clicking the button to the right with the minus sign on the label. New filters are added from the pulldown lists at the bottom corners of the filters box ('And' conditions on the left, 'Or' conditions on the right). Filters with either a text box or a pulldown menu of options can be added multiple times to perform an or of the criteria.

You can use the fields just below the filters box to group the results based on a field, or display the full description for each ticket.

Once you've edited your filters click the Update button to refresh your results.

Clicking on one of the query results will take you to that ticket. You can navigate through the results by clicking the Next Ticket or Previous Ticket links just below the main menu bar, or click the Back to Query link to return to the query page.

You can safely edit any of the tickets and continue to navigate through the results using the Next/Previous/Back to Query links after saving your results. When you return to the query any tickets which were edited will be displayed with italicized text. If one of the tickets was edited such that it no longer matches the query criteria the text will also be greyed. Lastly, if a new ticket matching the query criteria has been created, it will be shown in bold.

The query results can be refreshed and cleared of these status indicators by clicking the Update button again.

Saving Queries

Trac allows you to save the query as a named query accessible from the reports module. To save a query ensure that you have Updated the view and then click the Save query button displayed beneath the results. You can also save references to queries in Wiki content, as described below.

Note: one way to easily build queries like the ones below, you can build and test the queries in the Custom report module and when ready - click Save query. This will build the query string for you. All you need to do is remove the extra line breaks.

You may want to save some queries so that you can come back to them later. You can do this by making a link to the query from any Wiki page.

[query:status=new|assigned|reopened&version=1.0 Active tickets against 1.0]

Which is displayed as:

Active tickets against 1.0

This uses a very simple query language to specify the criteria (see Query Language).

Alternatively, you can copy the query string of a query and paste that into the Wiki link, including the leading ? character:

[query:?status=new&status=assigned&status=reopened&group=owner Assigned tickets by owner]

Which is displayed as:

Assigned tickets by owner

Using the [[TicketQuery]] Macro

The TicketQuery macro lets you display lists of tickets matching certain criteria anywhere you can use WikiFormatting.

Example:

[[TicketQuery(version=0.6|0.7&resolution=duplicate)]]

This is displayed as:

No results

Just like the query: wiki links, the parameter of this macro expects a query string formatted according to the rules of the simple ticket query language.

A more compact representation without the ticket summaries is also available:

[[TicketQuery(version=0.6|0.7&resolution=duplicate, compact)]]

This is displayed as:

No results

Finally if you wish to receive only the number of defects that match the query using the count parameter.

[[TicketQuery(version=0.6|0.7&resolution=duplicate, count)]]

This is displayed as:

0

Customizing the table format

You can also customize the columns displayed in the table format (format=table) by using col=<field> - you can specify multiple fields and what order they are displayed by placing pipes (|) between the columns like below:

[[TicketQuery(max=3,status=closed,order=id,desc=1,format=table,col=resolution|summary|owner|reporter)]]

This is displayed as:

Results (1 - 3 of 5)

1 2
Ticket Resolution Summary Owner Reporter
#6 fixed Very IMPORTANT: Added new 4DVAR operator for HF radials arango
#5 fixed typo in ad_zetabc.F somebody zhang
#4 fixed '#' is missing in tl_wrt_ini.F somebody zhang
1 2

Full rows

In table format you can also have full rows by using rows=<field> like below:

[[TicketQuery(max=3,status=closed,order=id,desc=1,format=table,col=resolution|summary|owner|reporter,rows=description)]]

This is displayed as:

Results (1 - 3 of 5)

1 2
Ticket Resolution Summary Owner Reporter
#6 fixed Very IMPORTANT: Added new 4DVAR operator for HF radials arango
Description

This update is not public and the only users having access to our omlab svn repository may use it. This is an ongoing funded research. This is my private research svn branch and very few have access to it.


The 4DVar data assimilation data operators were updated to allow extra-observations type classes with multiple correspondences with the model state variables. Previously, the observation operator in obs_write.F (NLM, TLM, RPM), ad_misfit.F (ADM, primal formulation), and ad_htobs.F (ADM, dual formulation) have one-to-one correspondence with each state variable (zeta, u, v, T, S, and other passive tracers). Recall that the observation operator spatially interpolates the model at the observation locations at the appropiate time. Examples of extra-observation classes include HF radials, travel time, pressure, etc. This updade includes the observation operator to process HF radar surface velocity meassurements (radials) that affect both u- and v-momentum state variables.

  • The input 4DVAR script s4dvar.in was modified to include the extra-observation parameters:
    ! In any application, the number of observation types is computed as:
    ! NobsVar = NstateVar + NextraObs.
    !
    ! NextraObs values are expected for keywords ExtraIndex and ExtraName.
    ! If NextraVar > 1, enter one observation type names per line and
    ! use a backslash as the continuation.
    
          NextraObs = 1
    
         ExtraIndex = 20
    
          ExtraName = radial
    
    
    Here, NextraObs is the number of extra-observation classes to consider in addition to those associated with the state variables (one-to-one correspondence). They are used in observation operators that require more that one state variable to evaluate a particular extra-observation type like HF radials, travel time, pressure, etc. In any application, the number of observation types is now computed as:
         NobsVar(ng) = NstateVar(ng) + NextraObs
    
    If not processing extra-observation classes, set NextraObs=0.

The parameter ExtraIndex defines the extra-observation class identification indices, as specified in the input observation NetCDF file variable obs_type. The index has to be unique and a number greater than 7+2*NT, where NT is the total of active plus passive tracers. The 7 values include zeta, ubar, vbar, u, v, sustr, and svstr. The 2 factor for NT is to account for the surface tracer flux. Therefore, avoid using 1:7+2*NT numbers for indices because they are reserved for the state vector. Be aware that you may want to use biological data assimilation in the future. NextraObs values are expected for this keyword. This parameter is only processed when NextraObs > 0.

The keyword ExtraName defines the extra-observation class names. NextraObs values are expected. This parameter is only processed when NextraObs > 0. Enter one type name per line and use a backslash for continuation. For example:

     ExtraName = radial   \
                 pressure

Currently, however, only the radials operator is coded.

  • A new variable obs_meta is added to the input observations NetCDF file:
    	double obs_meta(datum) ;
    		obs_meta:long_name = "observation meta value" ;
    		obs_meta:units = "associated state variable units" ;
    
    The variable obs_meta contains additional data qualifiers for the extra-observation value specified in obs_value. For example, it contains the velocity radials angle (radians) from HF Radar data. The values in obs_meta for any non-radial observation are ignored.

In curvilinear coordinates, the velocity radial is defined as:

    radial = u * COS(obs_meta - angler) + v * SIN(obs_meta - angler)

where angler is the curviliar rotation angle. If no curvlinear grid, angler=0.

  • Introduced mapping indices from state variable to observation type (ObsState2Type) and its inverse from observation type to state variable (ObsType2State). It is done because the extra-observation index (ExtraIndex) may not be in sequential enumeration with respect to regular observation types.

In routine initial_fourdvar of mod_fourdvar.F, these mapping indices are allocated and initialized as follows:

!
!  Allocate and initialize observation types names and indices.
!  Notice that a mapping from state-to-type (ObsState2Type) and its
!  inverse type-to-state (ObsType2State) indices are needed because
!  the User is allowed to add extra-observation operators with
!  nonsequential type enumeration.
!
!  Both mapping arrays ObsState2Type and ObsType2State have a zero
!  array element to allow applications with no extra-observations
!  to work with their zero associated state index (as initialized
!  in mod_ncparam.F).  For example, if the index "isRadial" is not
!  redefined below, the following assignment
!
!        ObsState2Type(isRadial)=ObsState2Type(0)=0
!        ObsType2State(isRadial)=ObsType2State(0)=0
!
!  is still legal with isRadial=0. It avoids a Fortran segmentation
!  violation (i.e., subscript #1 of the array ObsState2Type has
!  value 0 which is less than the lower bound of 1).  Sorry for
!  the awkward logic but we need a generic way to specify extra-
!  observation operators.
!
      allocate ( ObsName(MAXVAL(NobsVar)) )
      icount=MAXVAL(NstateVar)
      ObsState2Type(0)=0
      DO i=1,icount                               ! 5+NT
        ObsState2Type(i)=i
        ObsName(i)=TRIM(Vname(1,idSvar(i)))
      END DO
      IF (NextraObs.gt.0) THEN
        DO i=1,NextraObs
          icount=icount+1
          ObsName(icount)=TRIM(ExtraName(i))
          SELECT CASE (TRIM(uppercase(ExtraName(i))))
            CASE ('RADIAL')
              isRadial=icount
              ObsState2Type(icount)=ExtraIndex(i)
          END SELECT
        END DO
      END IF

In obs_write.F, the ObsState2Type is used as follows:

          CALL extract_obs3d (ng, 1, Lm(ng)+1, 0, Mm(ng)+1,             &
     &                        LBi, UBi, LBj, UBj, 1, N(ng),             &
     &                        ObsState2Type(isRadial),                  & !<==
     &                        Mobs, Mstr, Mend,                         &
     &                        uXmin(ng)+0.5_r8, uXmax(ng)+0.5_r8,       &
     &                        uYmin(ng), uYmax(ng),                     &
     &                        time(ng), dt(ng),                         &
     &                        ObsType,  ObsVetting,                     &
     &                        Tobs, Xobs+0.5_r8, Yobs, Zobs,            &
     &                        OCEAN(ng)%u(:,:,:,NOUT),                  &
     &                        GRID(ng)%z_v,                             &
#   ifdef MASKING
     &                        GRID(ng)%umask,                           &
#   endif
     &                        uradial)

In obs_cost.F, the reverse mapping ObsType2State is used as follows:

       DO iobs=NstrObs(ng),NendObs(ng)
         ivar=ObsType2State(ObsType(iobs))                        !<==                                                       
         IF ((ivar.gt.0).and.(ObsScale(iobs).gt.0.0_r8).and.           &
    &        (ObsErr(iobs).ne.0.0_r8)) THEN
           cff=ObsScale(iobs)*(NLmodVal(iobs)-ObsVal(iobs))**2/        &
    &          ObsErr(iobs)
           my_ObsCost(0)=my_ObsCost(0)+cff
           my_ObsCost(ivar)=my_ObsCost(ivar)+cff
         END IF
       END DO
  • Modified routined obs_write.F, ad_misfit.F, and ad_htob.F to include the HF Radar data operator:
    !
    !  Compute NLM radial velocity.
    !
              DO iobs=Mstr,Mend
                IF (ObsType(iobs).eq.ObsState2Type(isRadial)) THEN
    #   ifdef CURVGRID
                  angle=ObsMeta(iobs)-ObsAngler(iobs)
                  NLmodVal(iobs)=uradial(iobs)*COS(angle)+                  &
         &                       vradial(iobs)*SIN(angle)
    #   else
                  NLmodVal(iobs)=uradial(iobs)*COS(ObsMeta(iobs))+          &
         &                       vradial(iobs)*SIN(ObsMeta(iobs))
    #   endif
    #   ifdef BGQC
                  BgErr(iobs)=MAX(uBgErr(iobs), vBgErr(iobs))
    #   endif
                END IF
              END DO
    
    where uradial and vradial are the model velocities interpolated to the radial velocity locations in space and time, obs_angler is the curvilinear grid angle interpolated at the radial locations, and obs_meta is the HF radar radial angle.

The adjoint forcing is simply:

        IF (FOURDVAR(ng)%ObsCount(isRadial).gt.0) THEN
          DO iobs=1,Nobs(ng)
            ad_uradial(iobs)=IniVal
            ad_vradial(iobs)=IniVal
          END DO
          DO iobs=1,Nobs(ng)
            IF (ObsType(iobs).eq.ObsState2Type(isRadial)) THEN
#  ifdef CURVGRID
              angle=ObsMeta(iobs)-ObsAngler(iobs)
              ad_uradial(iobs)=ad_uradial(iobs)+                        &
     &                         ADmodVal(iobs)*COS(angle)
              ad_vradial(iobs)=ad_vradial(iobs)+                        &
     &                         ADmodVal(iobs)*SIN(angle)
#  else
              ad_uradial(iobs)=ad_uradial(iobs)+                        &
     &                         ADmodVal(iobs)*COS(ObsMeta(iobs))
              ad_vradial(iobs)=ad_vradial(iobs)+                        &
     &                         ADmodVal(iobs)*SIN(ObsMeta(iobs))
#  endif
            END IF
          END DO
          ...
        END IF

  • The HF radial assimilation was tested with Brian Powell Hawaii application. Both IS4DVAR and W4DPSAS gives identical cost functions.

https://www.myroms.org/trac/hawaii_radials_penalty.png


Many thanks to Brain Powell for his help in the coding and testing of the HF Radar operator to assimilate surface velocity radials.


Corrected a bug in ad_misfit.F and obs_write.F in the managing of the screening and quality control variable obs_scale for the primal formulation. The issue is that in the primal formulation (IS4DVAR), the current time window (or survey) observations are loaded to the working arrays using local indices (array elements 1:Nobs) as opposed to global indices in the dual formulation (W4DPSAS and W4DVAR). Recall that the screening variable ObsScale is computed only once to facilitate Background Quality Control on the first pass of the NLM (WrtObsScale=T and wrtNLmod=T). Therefore, we need to load and save values into global array ObsScaleGlobal so it can be used correctly by the TLM, RPM, and ADM.

# ifndef WEAK_CONSTRAINT
!
!-----------------------------------------------------------------------
!  Save observation reject/accept flag in GLOBAL screening variable.
!-----------------------------------------------------------------------
!
        IF (wrtObsScale(ng).and.wrtNLmod(ng)) THEN
          ic=0
          DO iobs=NstrObs(ng),NendObs(ng)
            ic=ic+1
            ObsScaleGlobal(iobs)=ObsScale(ic)
          END DO
        ELSE
          ic=0
          DO iobs=NstrObs(ng),NendObs(ng)
            ic=ic+1
            ObsScale(ic)=ObsScaleGlobal(iobs)
          END DO
        END IF
# endif

Then, in ad_misfit.F, we just need to load the correct ObsScale for the current time assimilation window:

!
!-----------------------------------------------------------------------
!  Load observation reject and accept flag into screening variable.
!-----------------------------------------------------------------------
!
        ic=0
        DO iobs=NstrObs(ng),NendObs(ng)
          ic=ic+1
          ObsScale(ic)=ObsScaleGlobal(iobs)
        END DO
#5 fixed typo in ad_zetabc.F somebody zhang
Description

in ad_zetabc.F, line 99: ad_Ce=0.0_r8

it should be: ad_Cx=0.0_r8

#4 fixed '#' is missing in tl_wrt_ini.F somebody zhang
Description

Line 395 in tl_wrt_ini.F.

'#' is missing in front of 'endif'

1 2

Query Language

query: TracLinks and the [[TicketQuery]] macro both use a mini “query language” for specifying query filters. Basically, the filters are separated by ampersands (&). Each filter then consists of the ticket field name, an operator, and one or more values. More than one value are separated by a pipe (|), meaning that the filter matches any of the values. To include a litteral & or | in a value, escape the character with a backslash (\).

The available operators are:

= the field content exactly matches the one of the values
~= the field content contains one or more of the values
^= the field content starts with one of the values
$= the field content ends with one of the values

All of these operators can also be negated:

!= the field content matches none of the values
!~= the field content does not contain any of the values
!^= the field content does not start with any of the values
!$= the field content does not end with any of the values

The date fields created and modified can be constrained by using the = operator and specifying a value containing two dates separated by two dots (..). Either end of the date range can be left empty, meaning that the corresponding end of the range is open. The date parser understands a few natural date specifications like "3 weeks ago", "last month" and "now", as well as Bugzilla-style date specifications like "1d", "2w", "3m" or "4y" for 1 day, 2 weeks, 3 months and 4 years, respectively. Spaces in date specifications can be left out to avoid having to quote the query string.

created=2007-01-01..2008-01-01 query tickets created in 2007
created=lastmonth..thismonth query tickets created during the previous month
modified=1weekago.. query tickets that have been modified in the last week
modified=..30daysago query tickets that have been inactive for the last 30 days

See also: TracTickets, TracReports, TracGuide

Note: See TracWiki for help on using the wiki.