Useful Programs and Functions

This section describes programs and functions available for general use. These functions are in addition to those supplied as part of the PostgreSQL system. Typically, one would use one of these programs as part of a special process not part of the regular Babase system. One would use one of these functions in a SQL - SELECT statement, a query, a report, or perhaps in a special purpose program, or a new Babase system program you might want to write. For more detailed information on the operation of these programs and functions see the documentation written into the program header of the program source code.

Documentation on the use of these programs can be found in the Protocol for Data Management: Amboseli Baboon Project and in this document. This document also contains the coding standards and design philosophy of the system, which should be followed by anyone modifying or adding programs to this directory.

Note

There are a large number of procedures and functions which are part of Babase but are not listed in the tables below. The unlisted functions either begin with the underscore (_) character, or end in _func.[307]

Functions

Only those functions in the table below are expected to be used by the typical end-user.

Table 8.1. The Babase SQL Functions

Name Description

rnkdate()

convert a date value to the first day of the month

date_mod()

return a remainder from a timestamp

spm()

convert time to seconds past midnight

spm_to()

convert from seconds past midnight to a time

julian()

convert a date or timestamp to a julian date

julian_to()

convert a julian date to a regular date

hydroyear()

compute the hydrological year a given date falls within

season()

compute the season a given date falls within

bb_makepoint()

produce a PostGIS geometry point in the WGS 1984 UTM Zone 37South coordinate system from X and Y coordinates

bb_makepoint_longlat()

produce a PostGIS geometry point in the WGS 1984 UTM Zone 37South coordinate system from longitude and latitude coordinates

corrected_hormone()

Convert a "raw" hormone concentration into a corrected concentration, using the provided mathematical expression.


Logout: Logout From Babase Custom Programs

The logout program logs the user out of the Babase web based collection of programs.

Note

Babase consists of many programs, only some of which are web based programs written specifically for Babase. The logout program only controls access to those programs written specifically for Babase, other off the shelf programs have their own logout mechanisms.

Note

Logout from Babase is automatic after a period of inactivity.[309]

Wwwdiff: World Wide Web based Difference program

The wwwdiff program compares two text files. It can be found on the Babase Web site.

Among other uses, this program provides a useful data validation mechanism. To validate data, have two different individuals enter the data and compare the results with the wwwdiff program. It is unlikely that both individuals will make identical errors and so almost all data transcription errors should be caught using this method.

Tip

The program uploads the two files to be compared. For security reasons most web browsers will always clear the names of the uploaded files once they have been uploaded. This makes it difficult to repeatedly upload the same or similar files, as when re-comparing two files after correcting errors. The situation is not as bad as it might sound because browsers will often provide a browse button and keep track of the directory last accessed, removing the need to re-navigate to the location of the data files. But it is still awkward to have to repeatedly point and click.

One solution is to use the browser's reload button. This will repeat the upload and comparison of the two files, but using the new, corrected, file content. A second, less desirable possibility is to have the have the pathnames of the files handy in a text document and cut and paste them as needed. A third possibility might be to use the browser's back button, but browsers will often clear the file upload information in this case in the same fashion they would with password information.

The wwwdiff program provides 5 comparison methods:

Tabular by Word -- Suppress identical lines

Like Tabular by Word, below, but identical lines are not displayed.

Tabular by Word

Useful where the data consists of individual words aligned as rows and columns of data. Compares the files contents on a word-by-word basis and displays the entire content of both files as a table with differences marked.

Caution

When one file contains whitespace[310] that is not in the other, this comparison method shows extra cells in the output. Words are separated by whitespace but because there is only extra whitespace the cells are empty. Thus, when one file contains more whitespace than the other those rows will contain more columns. Normally the data in the extra cells would be color coded to inform as to whence they came, but because the cells are empty there is nothing to color code. The operator must compare the files by hand to determine which file contains the extra whitespace.

By Word

Useful where the data consists of words and there are relatively few changes or where paragraphs have been refilled and words have moved from line to line. Compares the file contents on a word-by-word basis displaying the entire content of both files as plain text.

By Line

Useful when there is a large amount of textual data. Compares the file contents on a line-by-line basis and displays only a small amount of context surrounding those portions of the text which differ between the files.

By File

Useful when comparing non-text files. Reports the location (by line and byte offset from the beginning of the files) of the first difference found.

Note

When comparing using any of the by word methods the reported line number increases by one when either: File A or File B contains an entirely new line not in the other file, or when a line in one file differs in every word from the same line in the other file. This throws the line numbering off relative to one or both of the original files.

Overview of Data Analysis Procedures

These procedures provide a mechanism for manually updating the analyzed data which Babase maintains. They are expected to be of use only to the data managers.

As a rule the analyzed data are kept up-to-date automatically by Babase (the exceptions are the CYCSTATS and the REPSTATS tables, and the MEMBERS.Supergroup and residency columns on MEMBERS), but at times it may be necessary to reconstruct the analyzed data. One such occasion would be the discovery of a bug in the Babase code which keeps the analyzed data up-to-date.

The procedures tend to come in pairs, one of which updates an entire table and the other of which updates only the data related to a specific Sname.

Data Analysis Procedures

Table 8.2. Data Analysis Procedures

Name Description

rebuild_automdates()

rebuild the automatic Mdates for an individual

rebuild_all_automdates()

rebuild the automatic Mdates of all individuals

rebuild_cycgapdays()

rebuild the table for an individual

rebuild_all_cycgapdays()

rebuild the entire table

rebuild_cycles()

rebuild the table for an individual

rebuild_all_cycles()

rebuild the entire table

rebuild_cycstats()

rebuild the table for an individual

rebuild_all_cycstats()

rebuild the entire table

rebuild_members()

re-interpolate the MEMBERS table for an individual, re-construct the Supergroup and Delayed_Supergroup columns, and re-analyze the residency information for the individual's MEMBERS rows

rebuild_all_members()

re-interpolate the MEMBERS table for all individuals, re-construct the Supergroup and Delayed_Supergroup columns, and re-analyze the residency information for all individuals' MEMBERS rows

rebuild_new_members()

for all individuals with any rows that haven't had their supergroups constructed or residency analyzed, re-interpolate all their MEMBERS rows, re-construct all their Supergroup and Delayed_Supergroup columns, and re-analyze the residency information for all their MEMBERS rows

rebuild_mdintervals()

rebuild the table for an individual

rebuild_all_mdintervals()

rebuild the entire table

rebuild_mmintervals()

rebuild the table for an individual

rebuild_all_mmintervals()

rebuild the entire table

rebuild_ranks()

rebuild the calculated columns in RANKS for all rows with a specific Grp, Rnkdate, and Rnktype

rebuild_ranks_grp_rnktype()

rebuild the calculated columns in RANKS for all rows with a specific Grp and Rnktype

rebuild_all_ranks()

rebuild the calculated columns in the entire table

rebuild_repstats()

rebuild the table for an individual

rebuild_all_repstats()

rebuild the entire table

rebuild_residency()

rebuild the residency related columns of the MEMBERS table and repopulate the RESIDENCIES table for an individual

rebuild_all_residency()

rebuild the residency related columns of the MEMBERS table and repopulate the entire RESIDENCIES table for all individuals

rebuild_new_residency()

rebuild the residency-related columns of the MEMBERS table and repopulate the entire RESIDENCIES table, but only for the individuals with MEMBERS rows that haven't already been analyzed

rebuild_sexskins()

rebuild the table for an individual

rebuild_all_sexskins()

rebuild the entire table

rebuild_supergroup()

rebuild the Supergroup and Delayed_Supergroup columns of the MEMBERS table for an individual

rebuild_all_supergroup()

rebuild the Supergroup and Delayed_Supergroup columns of the entire MEMBERS table

rebuild_new_supergroup()

rebuild the Supergroup and Delayed_Supergroup columns of the entire MEMBERS table for all individuals who have any rows that have not had their Supergroup or Delayed_Supergroup built

delete_census(sname, from, through)

Rapidly delete old style CENSUS rows




[307] Those that end in _func are the procedures used by the triggers for data validation.

[309] Currently 1 hour.

[310] Spaces, tabs, and whatever other characters that can't been seen.


Page generated: 2024-04-22T16:19:44-04:00.