a. beelen, ias, france1 flexbol database : an introduction alexandre beelen ias, orsay, france...
Post on 19-Dec-2015
235 views
TRANSCRIPT
A. Beelen, IAS, France 1
Flexbol database :an introduction
Alexandre BEELENIAS, Orsay, France
• PHP/MySQL• System management• Database design• flexbol scripts• Time accounting• an example• Authorization• Future
A. Beelen, IAS, France 2
Flexbol database : PHP/MySQL
• PHP (http://www.php.net)– Script language to create dynamical HTML pages– These pages could be classical HTML pages, but with PHP
code.<HTML> <HEAD> <TITLE>Test of PHP</TITLE></HEAD>
<BODY>
<?php echo “Hello World !"; ?>
</BODY> </HTML>
– Syntax similar to language C with loans in Perl and Java– PHP scripts are interpreted by the server– The source code is not available from the produced page– Interface with Database : Oracle, Sybase, MySQL, ODBC…– Works on most UNIX/Linux/BSD/NT platform
A. Beelen, IAS, France 3
Flexbol database : PHP/MySQL
• MySQL (http://www.mysql.org)– MySQL is a relational database management system.
• ODBC compliant• SQL = Strutured Query Language
SELECT * FROM database WHERE field0 = 1
– Separate tables instead putting all data in one big storeroom• One database, multiple tables• Tables are linked speed and flexibility
– Possibility to combine data from several tables on requestSELECT table1.field1, table2.field3 FROM table1, table2 WHERE table1.field2 = table2.field2
– Multi-users, multi-threaded– Easy interface to/from PHP– Works on most UNIX/Linux/BSD platform
A. Beelen, IAS, France 4
Flexbol database : System management
• PHP server– Web scripts module (Apache, Ms IIIS, Netscape, iPlan )– In line scripts PHP executable– Programs with GUI PHP-GTK– phpMyAdmin set of tools to manipulate MySQL table
• MySQL server– Server on any supported platform– Does not need to be on the same server of the PHP/Web server
• Web Server– Apache provide easy interface with PHP & MySQL.– Large variety of platform
Apache Server with PHP module & MySQL ‘currently’ installed on mrt-lx2
MySQL 3.22.32 / 3.23.49aPHP 4.0.0 / 4.1.2Apache 1.3.12 / 1.3.23
A. Beelen, IAS, France 5
Flexbol database : System management
LOGBOOK.ALL
MySQL server
PHP/WEB Server
HTML Page
phpMyAdmin
Flex_bol scripts
HTML Page
.cat files MySQL Database
A. Beelen, IAS, France 6
Flexbol database : Database design
• The most critical point – All depends on the design of the database
• One table to log the observations– LOGBOOK.ALL logbook
• One table to list the sources – *.CAT source
• One table to rules them all– session
A. Beelen, IAS, France 7
• Obs program log example
15-FEB-02 PROJECT: FLEXBOL OBSERVER: lutz OPERATOR: fernando
--------------------------------------------------------------------------------------------------------------------------------
SCAN|SOURCE |BAS|LAMBDA |BETA |VEL | |COL*|NULE|SFCZ|UT |AZM|ELV|OFF_1|OFF_2| |ISS|SSTI|BE|FREQUENCY| |LINE
|PROCEDURE | | | | | | | | | | | |REF_1|REF_2| | | |BE|FREQUENCY| |LINE
--------------------------------------------------------------------------------------------------------------------------------
7864|HERO-2 | -1|13:24:22.3| 27:29:01| 0|L| -2| 0|-1.9|00:31| 86| 45| 0| 0|H| 16| 10|10|250.00000|L|CONT
|ONOFF | | | | | | | | | | | | 150| 0| | | | | | |
7865|HERO-2 | -1|13:24:22.3| 27:29:01| 0|L| -2| 0|-1.9|00:35| 87| 46| 0| 0|H| 16| 10|10|250.00000|L|CONT
|ONOFF | | | | | | | | | | | | 150| 0| | | | | | |
7866|HERO-2 | -1|13:24:22.3| 27:29:01| 0|L| -2| 0|-1.9|00:39| 88| 47| 0| 0|H| 16| 10|10|250.00000|L|CONT
|ONOFF | | | | | | | | | | | | 150| 0| | | | | | |
7867| 1308+326 | 1|13:08:07.5| 32:36:40| 0|L| -2| 0|-1.9|00:42| 88| 48| 0| 0|H| 4| 30|10|250.00000|L|CONT
|POINTING | | | | | | | | | | | | 150| 0| | | | | | |
7868| 1308+326 | 1|13:08:07.5| 32:36:40| 0|L| -2| 1|-1.9|00:45| 83| 53| 0| 0|H| 6| 10|10|250.00000|L|CONT
*|FOCUS | | | | | | | | | | | | 150| 0| | | | | | |
Flexbol database : LOGBOOK.ALL
date Observer name Operator name
Scan numberObs. flag
Name of objectType of scan
Type of observation(planet/galactic/extragalactic)
Coordinates of observation corrections
UTAzimuthElevation Number of subscan
Time per subscan (in sec)
A. Beelen, IAS, France 8
The logbook table : Image of the LOGBOOK.ALL file
Flexbol database : Database design
Field Type Attributes Default Extra
ID int(10) UNSIGNED 0 auto_increment/unique/primary
SCAN smallint(10) UNSIGNED 0
SOURCE char(10) 0
PROC tinyint(3) UNSIGNED 0
COL tinyint(4) 0
NULE tinyint(4) 0
SFCZ float(10.2) 0.00
UT char(5) 0
AZM mediumint(3) 0
ELV tinyint(3) 0
ISS tinyint(3) 0
SSTI tinyint(4) 0
DATE date 0000-00-00
OBSERVER char(7)
OPERATOR char(7)
FLAG tinyint(1) 1
Unique Identification
Scan number
Source name
Type of observation
Correction factor
U.T.
Azimuth
Elevation
Number of subscan
Time for each subscan
Date of observation
Observer name
Operator name
Scan cancelled ?
A. Beelen, IAS, France 9
The .cat file contains sources list for each project• 150.cat :
INDIVIDUAL: SNAM SLAM SBET
COMMON: SBAS -1 ! using J 2000.0 coordinates
!
!! ********** QSOs at z =2 **************
!
! SOURCE RA DEC Z Mb
!
SNAM= ahso1555 ; SLAM= 00 17 33.3 ; SBET= +15 55 09 ; ! 2.110 -24.7
SNAM= 02250033 ; SLAM= 02 25 47.9 ; SBET= +00 33 29 ; ! 2.092 -24.5
SNAM= 07076909 ; SLAM= 07 26 17.8 ; SBET= +69 09 22 ; ! 2.100 -25.7
SNAM= 09144615 ; SLAM= 09 14 03.6 ; SBET= +46 15 50 ; ! 2.180 -26.1
SNAM= 09144610 ; SLAM= 09 14 04.1 ; SBET= +46 10 45 ; ! 2.180 -24.7
SNAM= 09243701 ; SLAM= 09 24 20.5 ; SBET= +37 01 19 ; ! 2.450 -24.9
SNAM= 09444732 ; SLAM= 09 44 27.2 ; SBET= +47 32 37 ; ! 2.103 -26.5
Flexbol database : .CAT file
Project number
Source name
Position of the source
comments
A. Beelen, IAS, France 10
The sources table : List all the sources
Flexbol database : Database design
Field Type Attributes Default Extra
id int(10) UNSIGNED 0 auto_increment/unique/primary
Name char(10)
Alpha char(15)
Delta char(15)
Priority tinyint(3) UNSIGNED 0
Project tinyint(3) UNSIGNED 0
Comment char(30)
Source ID
Name of the source
Position of the source
Priority within the project
Project number
Comments
A. Beelen, IAS, France 11
The session table : List all the projects
Flexbol database : Database design
Field Type Attributes Default Extra
id tinyint(3) UNSIGNED 0 auto_increment/unique/primary
investigator char(20)
title char(30)
descr char(200)
mode tinyint(4) UNSIGNED 0
atime int(10) UNSIGNED 0
ptime int(10) UNSIGNED 0
priority tinyint(3) UNSIGNED 0
w_c tinyint(2) UNSIGNED 0
w_t tinyint(2) UNSIGNED 0
w_s char(1)
remark char(50)
command char(30)
Project number
PI name
Title of the project
Short description
Mode of observation
Allowed time
Time spent
Priority of the project
Weather condition
Remark
Path to the command file
live example
A. Beelen, IAS, France 12
Flexbol database : flexbol scripts
session.php
project.php logbook.php
edit_project.phpedit_source.php
db.inc refresh.inc var.inc convert.inc cat.inc
List all projects
Display the logbookList all sources
of a project
Edit sourceinformation
Edit projetinformation
Database connection information
Refresh database from LOGBOOK.ALL
Contain allvariables
Routine to convert UT
to LST
Read the cat file
A. Beelen, IAS, France 13
Flexbol database : flexbol scripts
edit_project.phpedit_source.php session.phpproject.php
logbook.php
cat.inc
convert.inc
db.inc
refresh.inc
var.inc
A. Beelen, IAS, France 14
Flexbol database : time accounting
• Source matching– 9/10 characters used for extragalactic sources in LOGBOOK.ALL
SUBSTRING(logbook.source,1,9) = SUBSTRING(sources.name,1,9)
• Overheard time– var.inc :
$observation_desc = array( "ON-OFF", "MAP",(…)
$overhead_time = array( 100, 40, (…)
• time computation – refresh.inc :
$ptime += ($iss*$ssti)*$flag*(1.+$overhead_time[$proc]*1./100);
– project.php :$time[$count++] = $t_ssti*$t_iss;
$stime+=$time[$i]*$flag[$i]*(1.+$overhead_time[$proc[$from]]*1./100); (…)
$ptime_n+=$stime; (…)
A. Beelen, IAS, France 15
• list_project.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><HTML><HEAD><TITLE>an example of php script</TITLE></HEAD><BODY><?phpinclude "db.inc"; // connect to the Db$year_list = array("2001","2002");foreach ($year_list as $key => $year) {
print "<BR>$year<BR>\n"; $query="SELECT logbook.scan FROM logbook, sources
WHERE SUBSTRING(logbook.source,1,9) = SUBSTRING(sources.name,1,9) AND sources.project = '$id' AND YEAR(DATE) < ".($year+1)." AND YEAR(DATE) >= $year ORDER BY DATE,SCAN";
$result = mysql_query($query,$db);while(list($scan) = mysql_fetch_row($result) ) {
$scan_file = $scan.".fits";print "$scan\n"; }
print "<BR>\n"; }?></BODY></HTML>
Flexbol database : an example
HTML Tag
PHP Tag
Include File Array definition
Foreach Loop Print command
SQL Query
While loop
Print Command
A. Beelen, IAS, France 16
Flexbol database : an example
• list_project.php?id=150
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>an example of php script</TITLE></HEAD>
<BODY>
<BR>2001<BR>
4937
4938
(…)
8325
8326
<BR>
<BR>2002<BR>
1211
1212
(…)
6943
6944
<BR>
<BODY></HTML>
A. Beelen, IAS, France 17
Flexbol database : Authorization
• Observer :– Need to access all projects informations– Permission to modify source/project information
• priority• source list
– Should not have the permission to modify• the flex_bol scripts• the database directly (phpMyAdmin)
• Internet :– Restricted access– Permit to each PI to modify his own project information
Different pages ?
A. Beelen, IAS, France 18
Flexbol database : Authorization
• MySQL– Password protection
– User/Password could/must be different of the passwd file
– Connection information remains in ONE file (db.inc)<?php
$db = mysql_pconnect('localhost','flexible','teide510');
mysql_select_db('flexible',$db);
?>
– Password in clear text Protect the access of this file
• Apache/PHP– .htaccess protection
– https authentification
– Php session (?)
A. Beelen, IAS, France 19
Flexbol database : Future
• Security Issue– Observer– Internet
• Retrieve the LOGBOOK.ALL directly– Permissions problems– LOGBOOK.ALL bug
• Comments database– Web interface
• Database backup• Sources identification
– now by name– by position
• Code optimisation
A. Beelen, IAS, France 20
Flexbol database : Future
• Printable forms– PHP can produce pdf files directly
• Generate the project tar file automatically– Even send email to PI !!
• Statistics– Easy to do with database
• New database :– Pointing sources– calibrators
• Graphics pages– PHP can produce images dynamically
• HTML 3.0/4.0 compatibility– Browser independent
• Pages Style– CSS– XML
Last but not least !!
• Reduce the data• Write the article• Send it directly to A&A• Open Champagne bottle