Download Flexbol Database - Institut d'Astrophysique Spatiale

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Flexbol database :
an introduction
Alexandre BEELEN
IAS, Orsay, France
•
•
•
•
•
•
•
•
PHP/MySQL
System management
Database design
flexbol scripts
Time accounting
an example
Authorization
Future
A. Beelen, IAS, France
1
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
2
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 request
SELECT 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
3
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.49a
PHP
4.0.0 / 4.1.2
Apache 1.3.12 / 1.3.23
A. Beelen, IAS, France
4
Flexbol database : System management
phpMyAdmin
MySQL server
PHP/WEB Server
HTML Page
Flex_bol scripts
.cat files
MySQL Database
LOGBOOK.ALL
A. Beelen, IAS, France
5
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
6
Flexbol database : LOGBOOK.ALL
• Obs program log example
date
Operator name
Observer name
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| |
|
| |
| |
Scan number
Obs. flag
Name of object
Type of scan
Coordinates of
observation
corrections
Type of observation
(planet/galactic/extragalactic)
UT
Azimuth
Elevation
A. Beelen, IAS, France
Number of subscan
Time per subscan (in sec)
7
Flexbol database : Database design
The logbook table : Image of the LOGBOOK.ALL file
Field
Type
Attributes
Default
Extra
Unique Identification
ID
int(10)
UNSIGNED
0
auto_increment/unique/primary
Scan number
SCAN
smallint(10)
UNSIGNED
0
Source name
SOURCE
char(10)
Type of observation
PROC
tinyint(3)
COL
tinyint(4)
0
NULE
tinyint(4)
0
SFCZ
float(10.2)
0.00
U.T.
UT
char(5)
0
Azimuth
AZM
mediumint(3)
0
Elevation
ELV
tinyint(3)
0
Number of subscan
ISS
tinyint(3)
0
Time for each subscan
SSTI
tinyint(4)
0
Date of observation
DATE
date
0000-00-00
Observer name
OBSERVER
char(7)
Operator name
OPERATOR
char(7)
Scan cancelled ?
FLAG
tinyint(1)
Correction factor
0
UNSIGNED
0
1
A. Beelen, IAS, France
8
Flexbol database : .CAT file
The .cat file contains sources list for each project
• 150.cat :
Project
number
INDIVIDUAL: SNAM SLAM SBET
COMMON: SBAS -1 ! using J 2000.0 coordinates
!
!!
********** QSOs at z =2 **************
!
! SOURCE
RA
DEC
!
SNAM= ahso1555 ; SLAM= 00 17 33.3 ; SBET= +15 55
SNAM= 02250033 ; SLAM= 02 25 47.9 ; SBET= +00 33
SNAM= 07076909 ; SLAM= 07 26 17.8 ; SBET= +69 09
SNAM= 09144615 ; SLAM= 09 14 03.6 ; SBET= +46 15
SNAM= 09144610 ; SLAM= 09 14 04.1 ; SBET= +46 10
SNAM= 09243701 ; SLAM= 09 24 20.5 ; SBET= +37 01
SNAM= 09444732 ; SLAM= 09 44 27.2 ; SBET= +47 32
Z
09
29
22
50
45
19
37
;
;
;
;
;
;
;
Source
name
!
!
!
!
!
!
!
2.110
2.092
2.100
2.180
2.180
2.450
2.103
Mb
-24.7
-24.5
-25.7
-26.1
-24.7
-24.9
-26.5
comments
Position of the
source
A. Beelen, IAS, France
9
Flexbol database : Database design
The sources table : List all the sources
Field
Type
Attributes
Default
Extra
Source ID
id
int(10)
UNSIGNED
0
auto_increment/unique/primary
Name of the source
Name
char(10)
Position of the source
Alpha
char(15)
Delta
char(15)
Priority within the project
Priority
tinyint(3)
UNSIGNED
0
Project number
Project
tinyint(3)
UNSIGNED
0
Comments
Comment
char(30)
A. Beelen, IAS, France
10
Flexbol database : Database design
The session table : List all the projects
Field
Type
Attributes
Default
Extra
Project number
id
tinyint(3)
UNSIGNED
0
auto_increment/unique/primary
PI name
investigator
char(20)
Title of the project
title
char(30)
Short description
descr
char(200)
Mode of observation
mode
tinyint(4)
UNSIGNED
0
Allowed time
atime
int(10)
UNSIGNED
0
Time spent
ptime
int(10)
UNSIGNED
0
Priority of the project
priority
tinyint(3)
UNSIGNED
0
w_c
tinyint(2)
UNSIGNED
0
w_t
tinyint(2)
UNSIGNED
0
w_s
char(1)
Remark
remark
char(50)
Path to the command file
command
char(30)
Weather condition
live example
A. Beelen, IAS, France
11
Flexbol database : flexbol scripts
List all projects
List all sources
of a project
Display the logbook
session.php
project.php
Edit source edit_source.php
information
logbook.php
edit_project.php
Edit projet
information
db.inc
refresh.inc
var.inc
convert.inc
cat.inc
Database
connection
information
Refresh database
from LOGBOOK.ALL
Contain all
variables
Routine to
convert UT
to LST
Read the
cat file
A. Beelen, IAS, France
12
Flexbol database : flexbol scripts
var.inc
project.php
convert.inc
db.inc
edit_source.php
cat.inc
edit_project.php
logbook.php
A. Beelen, IAS, France
session.php
refresh.inc
13
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
14
Flexbol database : an example
• list_project.php
HTML Tag 


PHP Tag 
Include File 
Array definition 
Foreach Loop 
Print command 
SQL Query 

While loop 
Print Command



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>an example of php script</TITLE></HEAD>
<BODY>
<?php
include "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>
A. Beelen, IAS, France
15
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
16
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
17
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
18
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
19
Flexbol database : Future
•
Printable forms
–
•
Generate the project tar file automatically
–
•
• Reduce the data
• Write the article
• Send it directly to A&A
• Open Champagne bottle
Pointing sources
calibrators
PHP can produce images dynamically
HTML 3.0/4.0 compatibility
–
•
Easy to do with database
Graphics pages
–
•
Last but not least !!
New database :
–
–
•
Even send email to PI !!
Statistics
–
•
PHP can produce pdf files directly
Browser independent
Pages Style
–
–
CSS
XML
A. Beelen, IAS, France
20
Related documents