libsim Versione 7.2.6
esempio_v7ddballe_multi.f90

/brief Programma esempio per l'uso di vol7d con DB-All.e

/brief Programma esempio per l'uso di vol7d con DB-All.eVengono estratte più reti

1! Copyright (C) 2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
2! authors:
3! Davide Cesari <dcesari@arpa.emr.it>
4! Paolo Patruno <ppatruno@arpa.emr.it>
5
6! This program is free software; you can redistribute it and/or
7! modify it under the terms of the GNU General Public License as
8! published by the Free Software Foundation; either version 2 of
9! the License, or (at your option) any later version.
10
11! This program is distributed in the hope that it will be useful,
12! but WITHOUT ANY WARRANTY; without even the implied warranty of
13! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14! GNU General Public License for more details.
15
16! You should have received a copy of the GNU General Public License
17! along with this program. If not, see <http://www.gnu.org/licenses/>.
18PROGRAM v7ddballe
19! Programma di esempio di estrazione dall'archivio DB-all.e
25
26IMPLICIT NONE
27
28TYPE(vol7d_dballe) :: v7d
29TYPE(vol7d_network) :: dummy_network,network(8)
30TYPE(datetime) :: ti, tf, tc
31TYPE(vol7d) :: vol_cumh, vol_cumd
32TYPE(timedelta) :: dt_cum
33CHARACTER(len=12) :: c
34INTEGER :: i,j, n
35REAL, POINTER :: vol2d(:,:), vol2d_cum(:,:)
36INTEGER :: un
37CHARACTER(len=512) :: filesim
38TYPE(geo_coordvect),POINTER :: macroa(:)
39INTEGER, ALLOCATABLE :: in_macroa(:)
40
41! Definisco le date iniziale e finale
42CALL init(ti, year=2007, month=3, day=18, hour=00)
43CALL init(tf, year=2007, month=3, day=21, hour=00)
44CALL init(dummy_network, 'generic')
45CALL init(network(1), 'rete11')
46CALL init(network(2), 'rete13')
47CALL init(network(3), 'rete15')
48CALL init(network(4), 'rete18')
49CALL init(network(5), 'rete19')
50CALL init(network(6), 'rete20')
51CALL init(network(7), 'rete21')
52CALL init(network(8), 'rete22')
53!CALL init(network(9), 'rete12')
54!CALL init(network(10), 'rete17')
55
56
57! Chiamo il costruttore della classe vol7d_dballe per il mio oggetto
58CALL init(v7d,dsn="test",user="test",password="")
59! Importo i dati, variabile 'B13011' della btable (precipitazione),
60! rete 18 (FIDUPO), 20 (SIMNBO), 21 (SIMNPR)
61CALL import(v7d, (/'B13011'/), network, timei=ti, timef=tf, set_network=dummy_network,varkind=(/"r"/))
62
63print*,shape(v7d%vol7d%voldatir)
64
65call export(v7d%vol7d)
66
67! Cumulo i dati su intervalli orari
68CALL init(dt_cum, hour=1)
69CALL vol7d_compute_stat_proc(v7d%vol7d, vol_cumh, 1, 1, dt_cum)
70! Mi faccio dare una "vista" bidimensionale dei miei dati
71CALL vol7d_get_voldatir(vol_cumh, (/vol7d_ana_d,vol7d_time_d/), vol2dp=vol2d_cum)
72! Stampo la media su tutte le stazioni ora per ora
73DO i = 1, SIZE(vol_cumh%time)
74 CALL getval(vol_cumh%time(i), simpledate=c)
75 n = count(vol2d_cum(:,i) /= rmiss)
76 IF (n > 0) THEN
77 print'(2A,G12.5)',c,' prec. media (mm): ', &
78 sum(vol2d_cum(:,i), mask=(vol2d_cum(:,i) /= rmiss))/n
79 ENDIF
80ENDDO
81
82! Cumulo i dati su intervalli giornalieri
83CALL init(dt_cum, day=1)
84CALL init(tc, year=2007, month=3, day=17, hour=00)
85CALL vol7d_compute_stat_proc(vol_cumh, vol_cumd, 1, 1, dt_cum, tc)
86! Mi faccio dare una "vista" bidimensionale dei miei dati
87CALL vol7d_get_voldatir(vol_cumd, (/vol7d_ana_d,vol7d_time_d/), vol2dp=vol2d_cum)
88
89! Importo un file con le macroaree Emilia Romagna
90un = open_package_file('polipciv4.dat', filetype_data)
91IF (un < 0) stop 1
92INQUIRE(unit=un, name=filesim)
93CLOSE(un)
94CALL import(macroa, shpfilesim=filesim)
95ALLOCATE(in_macroa(SIZE(vol_cumd%ana)))
96in_macroa = 0
97! Determino l'appartenenza delle stazioni alle macroaree
98DO i = 1, SIZE(vol_cumd%ana)
99 DO j = 1, SIZE(macroa)
100 IF (geo_coord_inside(vol_cumd%ana(i)%coord, macroa(j))) THEN
101 in_macroa(i) = j
102 cycle
103 ENDIF
104 ENDDO
105ENDDO
106
107! Stampo la media su tutte le stazioni di ogni macroarea giorno per giorno
108DO i = 1, SIZE(vol_cumd%time)
109 CALL getval(vol_cumd%time(i), simpledate=c)
110 DO j = 1, SIZE(macroa)
111 n = count(vol2d_cum(:,i) /= rmiss .AND. in_macroa(:) == j)
112 IF (n > 0) THEN
113 print'(2A,I3,A,G12.5)',c,' macroarea: ',j,' prec media (mm): ', &
114 sum(vol2d_cum(:,i), mask=(vol2d_cum(:,i) /= rmiss &
115 .AND. in_macroa(:) == j))/n
116 ENDIF
117 ENDDO
118ENDDO
119
120END PROGRAM v7ddballe
Restituiscono il valore dell'oggetto nella forma desiderata.
Costruttori per le classi datetime e timedelta.
Scrittura su file.
Lettura da file.
Classi per la gestione delle coordinate temporali.
Utilities for managing files.
Extension of vol7d_class with methods for performing simple statistical operations on entire volumes ...
Classe per la gestione di un volume completo di dati osservati.
classe per import ed export di volumi da e in DB-All.e

Generated with Doxygen.