libsim Versione 7.2.6

◆ invalidatedi()

elemental logical function invalidatedi ( integer, intent(in) flag)
private

Data invalidated check.

Parametri
[in]flagattributo di invalidazione del dato

Definizione alla linea 900 del file modqc.F90.

901! Copyright (C) 2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
902! authors:
903! Davide Cesari <dcesari@arpa.emr.it>
904! Paolo Patruno <ppatruno@arpa.emr.it>
905
906! This program is free software; you can redistribute it and/or
907! modify it under the terms of the GNU General Public License as
908! published by the Free Software Foundation; either version 2 of
909! the License, or (at your option) any later version.
910
911! This program is distributed in the hope that it will be useful,
912! but WITHOUT ANY WARRANTY; without even the implied warranty of
913! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
914! GNU General Public License for more details.
915
916! You should have received a copy of the GNU General Public License
917! along with this program. If not, see <http://www.gnu.org/licenses/>.
918#include "config.h"
919!> \defgroup qc Libsim package, qc library.
920!! Procedures for data quality control.
921!! At the moment only climatological quality control is implemented
922
923!> Utilities and defines for quality control.
924!!
925!! Concise, high-value definitions of Data Quality by expert users,
926!! analysts, implementers and journalists. This is a great starting point
927!! to learn about Data Quality.
928!!
929!! Data Quality: The Accuracy Dimension
930!!
931!! "Data quality is defined as follows: data has quality if it satisfies
932!! the requirements of its intended use. It lacks quality to the extent
933!! that it does not satisfy the requirement. In other words, data quality
934!! depends as much on the intended use as it does on the data itself. To
935!! satisfy the intended use, the data must be accurate, timely, relevant,
936!! complete, understood, and trusted." Jack E. Olson
937!!
938!! No Data Left Behind: Federal Student Aid - A Case History
939!!
940!! "Data quality institutionalizes a set of repeatable processes to
941!! continuously monitor data and improve data accuracy, completeness,
942!! timeliness and relevance." Holly Hyland and Lisa Elliott, Federal
943!! Student Aid
944!!
945!! Data Quality: It's a Family Affair
946!!
947!! Data Quality definition: "The state of completeness, consistency,
948!! timeliness and accuracy that makes data appropriate for a specific
949!! use." Wim Helmer, Dun & Bradstreet
950!!
951!! Data Quality and Quality Management - Examples of Quality Evaluation
952!! Procedures and Quality Management in European National Mapping
953!! Agencies
954!!
955!! "Quality is defined as the totality of characteristics of a product
956!! that bear on its ability to satisfy stated and implied needs (ISO
957!! 8402, 1994). In the new ISO/DIS 9000:2000 standard (2000) the
958!! definition of quality is: 'Ability of a set of inherent
959!! characteristics of a product, system or process to fulfill
960!! requirements of customers and other interested parties.' This
961!! indicates that data quality and quality management are very closely
962!! related. Data quality is part of the organisation's total quality
963!! management." Antti Jakobsson
964!!
965!! text below from Wikipedia
966!! http://it.wikipedia.org/wiki/Test_di_verifica_d%27ipotesi
967!! http://creativecommons.org/licenses/by-sa/3.0/deed.it
968!! L'ambito statistico
969!!
970!! Nel secondo caso la situazione è modificata in quanto interviene un
971!! elemento nuovo, ovvero il caso. Si supponga di avere una moneta
972!! recante due facce contrassegnate con testa e croce. Volendo verificare
973!! l'ipotesi di bilanciamento della moneta si eseguono 20 lanci e si
974!! contano quelli che danno esito testa. La conseguenza del bilanciamento
975!! consiste nell'osservare un valore di teste attorno a 10. Tuttavia
976!! anche in ipotesi di bilanciamento non si può escludere di osservare 20
977!! teste. D'altronde, l'ipotesi di bilanciamento è logicamente
978!! compatibile con un numero di teste variante da 0 a 20. In tale
979!! contesto una qualsiasi decisione in merito all'ipotesi da verificare
980!! comporta un rischio di errore. Ad esempio rigettare l'ipotesi di
981!! bilanciamento della moneta avendo osservato 20 teste su 20 lanci
982!! comporta il rischio di prendere una decisione errata. Nel procedere
983!! alla verifica dell'ipotesi di bilanciamento della moneta, si ricorre a
984!! una variabile casuale X. Tale variabile casuale X è una variabile
985!! aleatoria discreta con distribuzione binomiale B(20; 0,5), dove 20
986!! indica il numero di lanci e 0,5 la probabilità che si verifichi
987!! l'evento "testa".
988!!
989!! Il risultato sperimentale si deve quindi confrontare con tale
990!! distribuzione: quanto è distante tale risultato dal valore medio della
991!! distribuzione B(20; 0,5)? Per rispondere alla domanda si deve
992!! individuare un valore caratteristico della distribuzione B(20;
993!! 0,5). Nel nostro caso tale valore caratteristico è il valore medio
994!! 20/2 = 10. Per valutare la distanza tra il valore sperimentale e
995!! quello atteso si valuta la probabilità di ottenere un valore
996!! sperimentale lontano dal valore medio di B(20; 0,5), ossia nel caso
997!! che dal nostro esperimento risulti X=15 (15 teste dopo 20 lanci), si
998!! calcola P{|X-10|>=15-10} quindi P{X<=5 oppure X>=15}=0,041.
999!!
1000!! Quindi, usando una moneta ben bilanciata, la probabilità di ottenere
1001!! un numero di teste X >= 15 (oppure X <= 5) dopo 20 lanci è pari a
1002!! 0,041 ossia al 4,1%. Giudicando bassa tale probabilità si rifiuterà
1003!! l'ipotesi di bilanciamento della moneta in esame, accettando quindi il
1004!! rischio del 4,1% di compiere un errore nel rifiutarla. Di solito, il
1005!! valore della probabilità adottato per rifiutare l'ipotesi nulla è <
1006!! 0,05. Tale valore è detto livello di significatività ed è definibile
1007!! come segue: il livello di significatività sotto l'ipotesi nulla è la
1008!! probabilità di cadere nella zona di rifiuto quando l'ipotesi nulla è
1009!! vera. Tale livello di significatività si indica convenzionalmente con
1010!! α. Il livello di significatività osservato α del test per il quale si
1011!! rifiuterebbe l'ipotesi nulla è detto valore-p (p-value). Riprendendo
1012!! l'esempio sopra riportato il valore-p è pari a 0,041. Adottando
1013!! nell'esempio α = 0,05, si rifiuterà l'ipotesi se
1014!! P{|X-10|>=x}<0,05. Tale condizione si raggiunge appunto se X<6 oppure
1015!! X>14. Tale insieme di valori si definisce convenzionalmente come
1016!! regione di rifiuto. Viceversa l'insieme { 6,7...14} si definisce regione
1017!! di accettazione. In questo modo si è costruita una regola di
1018!! comportamento per verificare l'ipotesi di bilanciamento della
1019!! moneta. Tale regola definisce il test statistico.
1020!!
1021!! In termini tecnici l'ipotesi da verificare si chiama ipotesi nulla e
1022!! si indica con H0, mentre l'ipotesi alternativa con H1. Nel caso della
1023!! moneta, se p è la probabilità di ottenere testa in un lancio la
1024!! verifica di ipotesi si traduce nel seguente sistema:
1025!!
1026!! H_0: p = \frac{1}{2}
1027!! H_1: p \ne \frac{1}{2}
1028!!
1029!! Come già osservato, il modo di condurre un test statistico comporta un
1030!! rischio di errore. Nella pratica statistica si individuano due tipi di
1031!! errori:
1032!!
1033!! 1. rifiutare H0 quando è vera, errore di primo tipo (α) (o errore di prima specie);
1034!! 2. accettare H0 quando è falsa, errore di secondo tipo (β) (o errore di seconda specie).
1035!!
1036!! Tornando all'esempio della moneta in cui la regione di accettazione è
1037!! data dall'insieme di valori {6..14}, la probabilità di rifiutare H0
1038!! quando è vera è stato calcolato pari a 0,041.Tale probabilità
1039!! rappresenta il rischio di incorrere in un errore di primo tipo e si
1040!! indica con α. Per valutare la probabilità di un errore di secondo tipo
1041!! è necessario specificare un valore di p in caso di verità di H1. Si
1042!! supponga che p=0,80, in tal caso la distribuzione di X è una
1043!! B(20;0,80)
1044!!
1045!! Con tale distribuzione di probabilità, l'errore di tipo 2 si calcola
1046!! sommando le probabilità relative ai valori di X della zona di
1047!! accettazione. Si trova quindi che la probabilità cercata è pari a
1048!! circa 0,20. Tale probabilità quantifica il rischio di incorrere
1049!! nell'errore di tipo 2. e si indica convenzionalmente con β. La
1050!! quantità 1-β si chiama potenza del test ed esprime quindi la capacità
1051!! di un test statistico riconoscere la falsità di H0 quando questa è
1052!! effettivamente falsa. La potenza del test trova applicazione nella
1053!! pratica statistica in fase di pianificazione di un esperimento.
1054!!
1055!!Scope of quality checks on observation values
1056!!Checks applied to determine the quality of an observation can range from the very simple to the
1057!!very complex. In roughly increasing order of complexity they can include:
1058!! * Syntactic checks (e.g. an air temperature must be a number to at most 1 decimal
1059!! place);
1060!! * Numeric ranges (e.g. the temperature must fall in the range -90 to +70);
1061!! * Climate range checks (i.e. is the datum consistent with climatology?)
1062!! * Intra-record consistency (e.g. the air temperature must not be less than the dew
1063!! point);
1064!! * Time-series consistency (e.g. the difference between two successive temperatures at
1065!! a site must be 'plausible'); and
1066!! * Spatial consistency (e.g. the station-dependent limits of plausible difference between
1067!! the temperatures at a station and its neighbours must not be violated).
1068!!\ingroup qc
1069module modqc
1070use kinds
1073use vol7d_class
1074
1075
1076implicit none
1077
1078
1079!> Definisce il livello di attendibilità per i dati validi
1080type :: qcpartype
1081 integer (kind=int_b):: att !< confidence for "*B33192" "*B33193" "*B33194"
1082 integer (kind=int_b):: gross_error ! special valuer for "*B33192" when gross error check failed
1083 integer (kind=int_b):: invalidated ! special valuer for "*B33196" when manual invalidation happen
1084end type qcpartype
1085
1086!> Default: data with confidence less or equal 10 are rejected
1087type(qcpartype) :: qcpar=qcpartype(10_int_b,0_int_b,1_int_b)
1088
1089integer, parameter :: nqcattrvars=4
1090CHARACTER(len=10),parameter :: qcattrvarsbtables(nqcattrvars)=(/"*B33196","*B33192","*B33193","*B33194"/)
1091
1092type :: qcattrvars
1093 TYPE(vol7d_var) :: vars(nqcattrvars)
1094 CHARACTER(len=10) :: btables(nqcattrvars)
1095end type qcattrvars
1096
1097!> Variables user in Quality Control
1098interface init
1099 module procedure init_qcattrvars
1100end interface
1101
1102!> Remove data under a defined grade of confidence.
1103interface peeled
1104 module procedure peeledrb, peeleddb, peeledbb, peeledib, peeledcb &
1105 ,peeledri, peeleddi, peeledbi, peeledii, peeledci &
1106 ,peeledrr, peeleddr, peeledbr, peeledir, peeledcr &
1107 ,peeledrd, peeleddd, peeledbd, peeledid, peeledcd &
1108 ,peeledrc, peeleddc, peeledbc, peeledic, peeledcc
1109end interface
1110
1111
1112!> Check data validity based on single confidence
1113interface vd
1114 module procedure vdi,vdb,vdr,vdd,vdc
1115end interface
1116
1117!> Check data validity based on gross error check
1118interface vdge
1119 module procedure vdgei,vdgeb,vdger,vdged,vdgec
1120end interface
1121
1122!> Test di dato invalidato
1123interface invalidated
1124 module procedure invalidatedi,invalidatedb,invalidatedr,invalidatedd,invalidatedc
1125end interface
1126
1127private
1128
1129public vd, vdge, init, qcattrvars_new, invalidated, peeled, vol7d_peeling
1130public qcattrvars, nqcattrvars, qcattrvarsbtables
1131public qcpar, qcpartype, qcsummaryflagb ! ,qcsummaryflagi
1132
1133contains
1134
1135
1136! peeled routines
1137#undef VOL7D_POLY_SUBTYPE
1138#undef VOL7D_POLY_SUBTYPES
1139#undef VOL7D_POLY_ISC
1140#define VOL7D_POLY_SUBTYPE REAL
1141#define VOL7D_POLY_SUBTYPES r
1142
1143#undef VOL7D_POLY_TYPE
1144#undef VOL7D_POLY_TYPES
1145#undef VOL7D_POLY_ISC
1146#undef VOL7D_POLY_TYPES_SUBTYPES
1147#define VOL7D_POLY_TYPE REAL
1148#define VOL7D_POLY_TYPES r
1149#define VOL7D_POLY_TYPES_SUBTYPES rr
1150#include "modqc_peeled_include.F90"
1151#include "modqc_peel_util_include.F90"
1152#undef VOL7D_POLY_TYPE
1153#undef VOL7D_POLY_TYPES
1154#undef VOL7D_POLY_TYPES_SUBTYPES
1155#define VOL7D_POLY_TYPE DOUBLE PRECISION
1156#define VOL7D_POLY_TYPES d
1157#define VOL7D_POLY_TYPES_SUBTYPES dr
1158#include "modqc_peeled_include.F90"
1159#include "modqc_peel_util_include.F90"
1160#undef VOL7D_POLY_TYPE
1161#undef VOL7D_POLY_TYPES
1162#undef VOL7D_POLY_TYPES_SUBTYPES
1163#define VOL7D_POLY_TYPE INTEGER
1164#define VOL7D_POLY_TYPES i
1165#define VOL7D_POLY_TYPES_SUBTYPES ir
1166#include "modqc_peeled_include.F90"
1167#include "modqc_peel_util_include.F90"
1168#undef VOL7D_POLY_TYPE
1169#undef VOL7D_POLY_TYPES
1170#undef VOL7D_POLY_TYPES_SUBTYPES
1171#define VOL7D_POLY_TYPE INTEGER(kind=int_b)
1172#define VOL7D_POLY_TYPES b
1173#define VOL7D_POLY_TYPES_SUBTYPES br
1174#include "modqc_peeled_include.F90"
1175#include "modqc_peel_util_include.F90"
1176#undef VOL7D_POLY_TYPE
1177#undef VOL7D_POLY_TYPES
1178#undef VOL7D_POLY_TYPES_SUBTYPES
1179#define VOL7D_POLY_TYPE CHARACTER(len=vol7d_cdatalen)
1180#define VOL7D_POLY_TYPES c
1181#define VOL7D_POLY_ISC = 1
1182#define VOL7D_POLY_TYPES_SUBTYPES cr
1183#include "modqc_peeled_include.F90"
1184#include "modqc_peel_util_include.F90"
1185
1186
1187#undef VOL7D_POLY_SUBTYPE
1188#undef VOL7D_POLY_SUBTYPES
1189#undef VOL7D_POLY_ISC
1190#define VOL7D_POLY_SUBTYPE DOUBLE PRECISION
1191#define VOL7D_POLY_SUBTYPES d
1192
1193#undef VOL7D_POLY_TYPE
1194#undef VOL7D_POLY_TYPES
1195#undef VOL7D_POLY_TYPES_SUBTYPES
1196#define VOL7D_POLY_TYPE REAL
1197#define VOL7D_POLY_TYPES r
1198#define VOL7D_POLY_TYPES_SUBTYPES rd
1199#include "modqc_peeled_include.F90"
1200#undef VOL7D_POLY_TYPE
1201#undef VOL7D_POLY_TYPES
1202#undef VOL7D_POLY_TYPES_SUBTYPES
1203#define VOL7D_POLY_TYPE DOUBLE PRECISION
1204#define VOL7D_POLY_TYPES d
1205#define VOL7D_POLY_TYPES_SUBTYPES dd
1206#include "modqc_peeled_include.F90"
1207#undef VOL7D_POLY_TYPE
1208#undef VOL7D_POLY_TYPES
1209#undef VOL7D_POLY_TYPES_SUBTYPES
1210#define VOL7D_POLY_TYPE INTEGER
1211#define VOL7D_POLY_TYPES i
1212#define VOL7D_POLY_TYPES_SUBTYPES id
1213#include "modqc_peeled_include.F90"
1214#undef VOL7D_POLY_TYPE
1215#undef VOL7D_POLY_TYPES
1216#undef VOL7D_POLY_TYPES_SUBTYPES
1217#define VOL7D_POLY_TYPE INTEGER(kind=int_b)
1218#define VOL7D_POLY_TYPES b
1219#define VOL7D_POLY_TYPES_SUBTYPES bd
1220#include "modqc_peeled_include.F90"
1221#undef VOL7D_POLY_TYPE
1222#undef VOL7D_POLY_TYPES
1223#undef VOL7D_POLY_TYPES_SUBTYPES
1224#define VOL7D_POLY_TYPE CHARACTER(len=vol7d_cdatalen)
1225#define VOL7D_POLY_TYPES c
1226#define VOL7D_POLY_TYPES_SUBTYPES cd
1227#include "modqc_peeled_include.F90"
1228
1229
1230#undef VOL7D_POLY_SUBTYPE
1231#undef VOL7D_POLY_SUBTYPES
1232#undef VOL7D_POLY_ISC
1233#define VOL7D_POLY_SUBTYPE INTEGER
1234#define VOL7D_POLY_SUBTYPES i
1235
1236#undef VOL7D_POLY_TYPE
1237#undef VOL7D_POLY_TYPES
1238#undef VOL7D_POLY_TYPES_SUBTYPES
1239#define VOL7D_POLY_TYPE REAL
1240#define VOL7D_POLY_TYPES r
1241#define VOL7D_POLY_TYPES_SUBTYPES ri
1242#include "modqc_peeled_include.F90"
1243#undef VOL7D_POLY_TYPE
1244#undef VOL7D_POLY_TYPES
1245#undef VOL7D_POLY_TYPES_SUBTYPES
1246#define VOL7D_POLY_TYPE DOUBLE PRECISION
1247#define VOL7D_POLY_TYPES d
1248#define VOL7D_POLY_TYPES_SUBTYPES di
1249#include "modqc_peeled_include.F90"
1250#undef VOL7D_POLY_TYPE
1251#undef VOL7D_POLY_TYPES
1252#undef VOL7D_POLY_TYPES_SUBTYPES
1253#define VOL7D_POLY_TYPE INTEGER
1254#define VOL7D_POLY_TYPES i
1255#define VOL7D_POLY_TYPES_SUBTYPES ii
1256#include "modqc_peeled_include.F90"
1257#undef VOL7D_POLY_TYPE
1258#undef VOL7D_POLY_TYPES
1259#undef VOL7D_POLY_TYPES_SUBTYPES
1260#define VOL7D_POLY_TYPE INTEGER(kind=int_b)
1261#define VOL7D_POLY_TYPES b
1262#define VOL7D_POLY_TYPES_SUBTYPES bi
1263#include "modqc_peeled_include.F90"
1264#undef VOL7D_POLY_TYPE
1265#undef VOL7D_POLY_TYPES
1266#undef VOL7D_POLY_TYPES_SUBTYPES
1267#define VOL7D_POLY_TYPE CHARACTER(len=vol7d_cdatalen)
1268#define VOL7D_POLY_TYPES c
1269#define VOL7D_POLY_ISC = 1
1270#define VOL7D_POLY_TYPES_SUBTYPES ci
1271#include "modqc_peeled_include.F90"
1272
1273
1274#undef VOL7D_POLY_SUBTYPE
1275#undef VOL7D_POLY_SUBTYPES
1276#undef VOL7D_POLY_ISC
1277#define VOL7D_POLY_SUBTYPE INTEGER(kind=int_b)
1278#define VOL7D_POLY_SUBTYPES b
1279
1280#undef VOL7D_POLY_TYPE
1281#undef VOL7D_POLY_TYPES
1282#undef VOL7D_POLY_TYPES_SUBTYPES
1283#define VOL7D_POLY_TYPE REAL
1284#define VOL7D_POLY_TYPES r
1285#define VOL7D_POLY_TYPES_SUBTYPES rb
1286#include "modqc_peeled_include.F90"
1287#undef VOL7D_POLY_TYPE
1288#undef VOL7D_POLY_TYPES
1289#undef VOL7D_POLY_TYPES_SUBTYPES
1290#define VOL7D_POLY_TYPE DOUBLE PRECISION
1291#define VOL7D_POLY_TYPES d
1292#define VOL7D_POLY_TYPES_SUBTYPES db
1293#include "modqc_peeled_include.F90"
1294#undef VOL7D_POLY_TYPE
1295#undef VOL7D_POLY_TYPES
1296#undef VOL7D_POLY_TYPES_SUBTYPES
1297#define VOL7D_POLY_TYPE INTEGER
1298#define VOL7D_POLY_TYPES i
1299#define VOL7D_POLY_TYPES_SUBTYPES ib
1300#include "modqc_peeled_include.F90"
1301#undef VOL7D_POLY_TYPE
1302#undef VOL7D_POLY_TYPES
1303#undef VOL7D_POLY_TYPES_SUBTYPES
1304#define VOL7D_POLY_TYPE INTEGER(kind=int_b)
1305#define VOL7D_POLY_TYPES b
1306#define VOL7D_POLY_TYPES_SUBTYPES bb
1307#include "modqc_peeled_include.F90"
1308#undef VOL7D_POLY_TYPE
1309#undef VOL7D_POLY_TYPES
1310#undef VOL7D_POLY_TYPES_SUBTYPES
1311#define VOL7D_POLY_TYPE CHARACTER(len=vol7d_cdatalen)
1312#define VOL7D_POLY_TYPES c
1313#define VOL7D_POLY_ISC = 1
1314#define VOL7D_POLY_TYPES_SUBTYPES cb
1315#include "modqc_peeled_include.F90"
1316
1317
1318#undef VOL7D_POLY_SUBTYPE
1319#undef VOL7D_POLY_SUBTYPES
1320#undef VOL7D_POLY_ISC
1321#define VOL7D_POLY_SUBTYPE CHARACTER(len=vol7d_cdatalen)
1322#define VOL7D_POLY_SUBTYPES c
1323
1324#undef VOL7D_POLY_TYPE
1325#undef VOL7D_POLY_TYPES
1326#undef VOL7D_POLY_TYPES_SUBTYPES
1327#define VOL7D_POLY_TYPE REAL
1328#define VOL7D_POLY_TYPES r
1329#define VOL7D_POLY_TYPES_SUBTYPES rc
1330#include "modqc_peeled_include.F90"
1331#undef VOL7D_POLY_TYPE
1332#undef VOL7D_POLY_TYPES
1333#undef VOL7D_POLY_TYPES_SUBTYPES
1334#define VOL7D_POLY_TYPE DOUBLE PRECISION
1335#define VOL7D_POLY_TYPES d
1336#define VOL7D_POLY_TYPES_SUBTYPES dc
1337#include "modqc_peeled_include.F90"
1338#undef VOL7D_POLY_TYPE
1339#undef VOL7D_POLY_TYPES
1340#undef VOL7D_POLY_TYPES_SUBTYPES
1341#define VOL7D_POLY_TYPE INTEGER
1342#define VOL7D_POLY_TYPES i
1343#define VOL7D_POLY_TYPES_SUBTYPES ic
1344#include "modqc_peeled_include.F90"
1345#undef VOL7D_POLY_TYPE
1346#undef VOL7D_POLY_TYPES
1347#undef VOL7D_POLY_TYPES_SUBTYPES
1348#define VOL7D_POLY_TYPE INTEGER(kind=int_b)
1349#define VOL7D_POLY_TYPES b
1350#define VOL7D_POLY_TYPES_SUBTYPES bc
1351#include "modqc_peeled_include.F90"
1352#undef VOL7D_POLY_TYPE
1353#undef VOL7D_POLY_TYPES
1354#undef VOL7D_POLY_TYPES_SUBTYPES
1355#define VOL7D_POLY_TYPE CHARACTER(len=vol7d_cdatalen)
1356#define VOL7D_POLY_TYPES c
1357#define VOL7D_POLY_ISC = 1
1358#define VOL7D_POLY_TYPES_SUBTYPES cc
1359#include "modqc_peeled_include.F90"
1360
1361
1362subroutine init_qcattrvars(this)
1363
1364type(qcattrvars),intent(inout) :: this
1365integer :: i
1366
1367this%btables(:) =qcattrvarsbtables
1368do i =1, nqcattrvars
1369 call init(this%vars(i),this%btables(i))
1370end do
1371
1372end subroutine init_qcattrvars
1373
1374
1375type(qcattrvars) function qcattrvars_new()
1376
1377call init(qcattrvars_new)
1378
1379end function qcattrvars_new
1380
1381
1382!> Remove data under the predefined grade of confidence.
1383!! If neither \a keep_attr nor \a delete_attr are passed, all the
1384!! attributes will be deleted after peeling; if \a keep_attr is
1385!! provided, only attributed listed in \a keep_attr will be kept in
1386!! output, (\a delete_attr will be ignored); if \a delete_attr is
1387!! provided, attributed listed in \a delete_attr will be deleted from
1388!! output.
1389SUBROUTINE vol7d_peeling(this, data_id, keep_attr, delete_attr, preserve, purgeana)
1390TYPE(vol7d),INTENT(INOUT) :: this !< object that has to be peeled
1391integer,INTENT(inout),pointer,OPTIONAL :: data_id(:,:,:,:,:) !< data ID to use with dballe DB (for fast write of attributes)
1392CHARACTER(len=*),INTENT(in),OPTIONAL :: keep_attr(:) !< Btable of attributes that should be kept after removing data
1393CHARACTER(len=*),INTENT(in),OPTIONAL :: delete_attr(:) !< Btable of attributes that should be deleted after removing data
1394logical,intent(in),optional :: preserve !< preserve all attributes if true (alternative to keep_attr and delete_attr)
1395logical,intent(in),optional :: purgeana !< if true remove ana with all data missing
1396
1397integer :: inddativar,inddatiattrinv,inddatiattrcli,inddatiattrtem,inddatiattrspa,inddativarattr
1398type(qcattrvars) :: attrvars
1399
1400INTEGER(kind=int_b),pointer :: invbb(:,:,:,:,:),clibb(:,:,:,:,:),tembb(:,:,:,:,:),spabb(:,:,:,:,:)
1401INTEGER,pointer :: invbi(:,:,:,:,:),clibi(:,:,:,:,:),tembi(:,:,:,:,:),spabi(:,:,:,:,:)
1402REAL,pointer :: invbr(:,:,:,:,:),clibr(:,:,:,:,:),tembr(:,:,:,:,:),spabr(:,:,:,:,:)
1403DOUBLE PRECISION,pointer :: invbd(:,:,:,:,:),clibd(:,:,:,:,:),tembd(:,:,:,:,:),spabd(:,:,:,:,:)
1404CHARACTER(len=vol7d_cdatalen),pointer :: invbc(:,:,:,:,:),clibc(:,:,:,:,:),tembc(:,:,:,:,:),spabc(:,:,:,:,:)
1405
1406call l4f_log(l4f_info,'starting peeling')
1407
1408call init(attrvars)
1409
1410! generate code per i vari tipi di dati di v7d
1411! tramite un template e il preprocessore
1412
1413
1414#undef VOL7D_POLY_SUBTYPE
1415#undef VOL7D_POLY_SUBTYPES
1416#define VOL7D_POLY_SUBTYPE REAL
1417#define VOL7D_POLY_SUBTYPES r
1418
1419#undef VOL7D_POLY_TYPE
1420#undef VOL7D_POLY_TYPES
1421#define VOL7D_POLY_TYPE REAL
1422#define VOL7D_POLY_TYPES r
1423#include "modqc_peeling_include.F90"
1424#undef VOL7D_POLY_TYPE
1425#undef VOL7D_POLY_TYPES
1426#define VOL7D_POLY_TYPE DOUBLE PRECISION
1427#define VOL7D_POLY_TYPES d
1428#include "modqc_peeling_include.F90"
1429#undef VOL7D_POLY_TYPE
1430#undef VOL7D_POLY_TYPES
1431#define VOL7D_POLY_TYPE INTEGER
1432#define VOL7D_POLY_TYPES i
1433#include "modqc_peeling_include.F90"
1434#undef VOL7D_POLY_TYPE
1435#undef VOL7D_POLY_TYPES
1436#define VOL7D_POLY_TYPE INTEGER(kind=int_b)
1437#define VOL7D_POLY_TYPES b
1438#include "modqc_peeling_include.F90"
1439#undef VOL7D_POLY_TYPE
1440#undef VOL7D_POLY_TYPES
1441#define VOL7D_POLY_TYPE CHARACTER(len=vol7d_cdatalen)
1442#define VOL7D_POLY_TYPES c
1443#include "modqc_peeling_include.F90"
1444
1445
1446#undef VOL7D_POLY_SUBTYPE
1447#undef VOL7D_POLY_SUBTYPES
1448#define VOL7D_POLY_SUBTYPE DOUBLE PRECISION
1449#define VOL7D_POLY_SUBTYPES d
1450
1451#undef VOL7D_POLY_TYPE
1452#undef VOL7D_POLY_TYPES
1453#define VOL7D_POLY_TYPE REAL
1454#define VOL7D_POLY_TYPES r
1455#include "modqc_peeling_include.F90"
1456#undef VOL7D_POLY_TYPE
1457#undef VOL7D_POLY_TYPES
1458#define VOL7D_POLY_TYPE DOUBLE PRECISION
1459#define VOL7D_POLY_TYPES d
1460#include "modqc_peeling_include.F90"
1461#undef VOL7D_POLY_TYPE
1462#undef VOL7D_POLY_TYPES
1463#define VOL7D_POLY_TYPE INTEGER
1464#define VOL7D_POLY_TYPES i
1465#include "modqc_peeling_include.F90"
1466#undef VOL7D_POLY_TYPE
1467#undef VOL7D_POLY_TYPES
1468#define VOL7D_POLY_TYPE INTEGER(kind=int_b)
1469#define VOL7D_POLY_TYPES b
1470#include "modqc_peeling_include.F90"
1471#undef VOL7D_POLY_TYPE
1472#undef VOL7D_POLY_TYPES
1473#define VOL7D_POLY_TYPE CHARACTER(len=vol7d_cdatalen)
1474#define VOL7D_POLY_TYPES c
1475#include "modqc_peeling_include.F90"
1476
1477
1478#undef VOL7D_POLY_SUBTYPE
1479#undef VOL7D_POLY_SUBTYPES
1480#define VOL7D_POLY_SUBTYPE INTEGER
1481#define VOL7D_POLY_SUBTYPES i
1482
1483#undef VOL7D_POLY_TYPE
1484#undef VOL7D_POLY_TYPES
1485#define VOL7D_POLY_TYPE REAL
1486#define VOL7D_POLY_TYPES r
1487#include "modqc_peeling_include.F90"
1488#undef VOL7D_POLY_TYPE
1489#undef VOL7D_POLY_TYPES
1490#define VOL7D_POLY_TYPE DOUBLE PRECISION
1491#define VOL7D_POLY_TYPES d
1492#include "modqc_peeling_include.F90"
1493#undef VOL7D_POLY_TYPE
1494#undef VOL7D_POLY_TYPES
1495#define VOL7D_POLY_TYPE INTEGER
1496#define VOL7D_POLY_TYPES i
1497#include "modqc_peeling_include.F90"
1498#undef VOL7D_POLY_TYPE
1499#undef VOL7D_POLY_TYPES
1500#define VOL7D_POLY_TYPE INTEGER(kind=int_b)
1501#define VOL7D_POLY_TYPES b
1502#include "modqc_peeling_include.F90"
1503#undef VOL7D_POLY_TYPE
1504#undef VOL7D_POLY_TYPES
1505#define VOL7D_POLY_TYPE CHARACTER(len=vol7d_cdatalen)
1506#define VOL7D_POLY_TYPES c
1507#include "modqc_peeling_include.F90"
1508
1509
1510#undef VOL7D_POLY_SUBTYPE
1511#undef VOL7D_POLY_SUBTYPES
1512#define VOL7D_POLY_SUBTYPE INTEGER(kind=int_b)
1513#define VOL7D_POLY_SUBTYPES b
1514
1515#undef VOL7D_POLY_TYPE
1516#undef VOL7D_POLY_TYPES
1517#define VOL7D_POLY_TYPE REAL
1518#define VOL7D_POLY_TYPES r
1519#include "modqc_peeling_include.F90"
1520#undef VOL7D_POLY_TYPE
1521#undef VOL7D_POLY_TYPES
1522#define VOL7D_POLY_TYPE DOUBLE PRECISION
1523#define VOL7D_POLY_TYPES d
1524#include "modqc_peeling_include.F90"
1525#undef VOL7D_POLY_TYPE
1526#undef VOL7D_POLY_TYPES
1527#define VOL7D_POLY_TYPE INTEGER
1528#define VOL7D_POLY_TYPES i
1529#include "modqc_peeling_include.F90"
1530#undef VOL7D_POLY_TYPE
1531#undef VOL7D_POLY_TYPES
1532#define VOL7D_POLY_TYPE INTEGER(kind=int_b)
1533#define VOL7D_POLY_TYPES b
1534#include "modqc_peeling_include.F90"
1535#undef VOL7D_POLY_TYPE
1536#undef VOL7D_POLY_TYPES
1537#define VOL7D_POLY_TYPE CHARACTER(len=vol7d_cdatalen)
1538#define VOL7D_POLY_TYPES c
1539#include "modqc_peeling_include.F90"
1540
1541
1542
1543#undef VOL7D_POLY_SUBTYPE
1544#undef VOL7D_POLY_SUBTYPES
1545#define VOL7D_POLY_SUBTYPE CHARACTER(len=vol7d_cdatalen)
1546#define VOL7D_POLY_SUBTYPES c
1547
1548#undef VOL7D_POLY_TYPE
1549#undef VOL7D_POLY_TYPES
1550#define VOL7D_POLY_TYPE REAL
1551#define VOL7D_POLY_TYPES r
1552#include "modqc_peeling_include.F90"
1553#undef VOL7D_POLY_TYPE
1554#undef VOL7D_POLY_TYPES
1555#define VOL7D_POLY_TYPE DOUBLE PRECISION
1556#define VOL7D_POLY_TYPES d
1557#include "modqc_peeling_include.F90"
1558#undef VOL7D_POLY_TYPE
1559#undef VOL7D_POLY_TYPES
1560#define VOL7D_POLY_TYPE INTEGER
1561#define VOL7D_POLY_TYPES i
1562#include "modqc_peeling_include.F90"
1563#undef VOL7D_POLY_TYPE
1564#undef VOL7D_POLY_TYPES
1565#define VOL7D_POLY_TYPE INTEGER(kind=int_b)
1566#define VOL7D_POLY_TYPES b
1567#include "modqc_peeling_include.F90"
1568#undef VOL7D_POLY_TYPE
1569#undef VOL7D_POLY_TYPES
1570#define VOL7D_POLY_TYPE CHARACTER(len=vol7d_cdatalen)
1571#define VOL7D_POLY_TYPES c
1572#include "modqc_peeling_include.F90"
1573
1574
1575
1576IF (.NOT.PRESENT(keep_attr) .AND. .NOT.PRESENT(delete_attr) .and. .not. optio_log(preserve)) THEN ! destroy all attributes
1577 IF (ASSOCIATED(this%voldatiattrr)) DEALLOCATE(this%voldatiattrr)
1578 IF (ASSOCIATED(this%voldatiattrd)) DEALLOCATE(this%voldatiattrd)
1579 IF (ASSOCIATED(this%voldatiattri)) DEALLOCATE(this%voldatiattri)
1580 IF (ASSOCIATED(this%voldatiattrb)) DEALLOCATE(this%voldatiattrb)
1581 IF (ASSOCIATED(this%voldatiattrc)) DEALLOCATE(this%voldatiattrc)
1582
1583 CALL delete(this%datiattr)
1584 CALL delete(this%dativarattr)
1585END IF
1586
1587IF (PRESENT(keep_attr)) THEN ! set to missing non requested attributes and reform
1588
1589 if (optio_log(preserve)) call l4f_log(l4f_warn,"preserve parameter ignored: keep_attr passed")
1590 CALL keep_var(this%datiattr%r)
1591 CALL keep_var(this%datiattr%d)
1592 CALL keep_var(this%datiattr%i)
1593 CALL keep_var(this%datiattr%b)
1594 CALL keep_var(this%datiattr%c)
1595 CALL qc_reform(this,data_id, miss=.true., purgeana=purgeana)
1596
1597ELSE IF (PRESENT(delete_attr)) THEN ! set to missing requested attributes and reform
1598
1599 if (optio_log(preserve)) call l4f_log(l4f_warn,"preserve parameter ignored: delete_attr passed")
1600 CALL delete_var(this%datiattr%r)
1601 CALL delete_var(this%datiattr%d)
1602 CALL delete_var(this%datiattr%i)
1603 CALL delete_var(this%datiattr%b)
1604 CALL delete_var(this%datiattr%c)
1605 CALL qc_reform(this,data_id, miss=.true., purgeana=purgeana)
1606
1607ELSE IF (PRESENT(purgeana)) THEN
1608
1609 CALL qc_reform(this,data_id, purgeana=purgeana)
1610
1611ENDIF
1612
1613
1614CONTAINS
1615
1616
1617!> Like vol7d_reform but manage data_id and have less options
1618subroutine qc_reform(this,data_id,miss, purgeana)
1619TYPE(vol7d),INTENT(INOUT) :: this !< object that has to be reformed
1620integer,INTENT(inout),pointer,OPTIONAL :: data_id(:,:,:,:,:) !< data ID to use with dballe DB (for fast write of attributes)
1621logical,intent(in),optional :: miss !< remove everithing related with missing position in description vector
1622logical,intent(in),optional :: purgeana !< if true remove ana with all data missing
1623
1624integer,pointer :: data_idtmp(:,:,:,:,:)
1625logical,allocatable :: llana(:)
1626integer,allocatable :: anaind(:)
1627integer :: i,j,nana
1628
1629if (optio_log(purgeana)) then
1630 allocate(llana(size(this%ana)))
1631 llana =.false.
1632 do i =1,size(this%ana)
1633 if (associated(this%voldatii)) llana(i)= llana(i) .or. any(c_e(this%voldatii(i,:,:,:,:,:)))
1634 if (associated(this%voldatir)) llana(i)= llana(i) .or. any(c_e(this%voldatir(i,:,:,:,:,:)))
1635 if (associated(this%voldatid)) llana(i)= llana(i) .or. any(c_e(this%voldatid(i,:,:,:,:,:)))
1636 if (associated(this%voldatib)) llana(i)= llana(i) .or. any(c_e(this%voldatib(i,:,:,:,:,:)))
1637 if (associated(this%voldatic)) llana(i)= llana(i) .or. any(c_e(this%voldatic(i,:,:,:,:,:)))
1638
1639#ifdef DEBUG
1640 if (.not. llana(i)) call l4f_log(l4f_debug,"remove station"//t2c(i))
1641#endif
1642
1643 end do
1644
1645 nana=count(llana)
1646
1647
1648 allocate(anaind(nana))
1649
1650 j=0
1651 do i=1,size(this%ana)
1652 if (llana(i)) then
1653 j=j+1
1654 anaind(j)=i
1655 end if
1656 end do
1657
1658
1659 if(present(data_id)) then
1660 allocate(data_idtmp(nana,size(data_id,2),size(data_id,3),size(data_id,4),size(data_id,5)))
1661 data_idtmp=data_id(anaind,:,:,:,:)
1662 if (associated(data_id))deallocate(data_id)
1663 data_id=>data_idtmp
1664 end if
1665
1666 call vol7d_reform(this,miss=miss,lana=llana)
1667
1668 deallocate(llana,anaind)
1669
1670else
1671
1672 call vol7d_reform(this,miss=miss)
1673
1674end if
1675
1676end subroutine qc_reform
1677
1678
1679SUBROUTINE keep_var(var)
1680TYPE(vol7d_var),intent(inout),POINTER :: var(:)
1681
1682INTEGER :: i
1683
1684IF (ASSOCIATED(var)) THEN
1685 if (size(var) == 0) then
1686 var%btable = vol7d_var_miss%btable
1687 else
1688 DO i = 1, SIZE(var)
1689 IF (all(var(i)%btable /= keep_attr(:))) THEN ! n.b. ALL((//)) = .TRUE.
1690 var(i)%btable = vol7d_var_miss%btable
1691 ENDIF
1692 ENDDO
1693 end if
1694ENDIF
1695
1696END SUBROUTINE keep_var
1697
1698SUBROUTINE delete_var(var)
1699TYPE(vol7d_var),intent(inout),POINTER :: var(:)
1700
1701INTEGER :: i
1702
1703IF (ASSOCIATED(var)) THEN
1704 if (size(var) == 0) then
1705 var%btable = vol7d_var_miss%btable
1706 else
1707 DO i = 1, SIZE(var)
1708 IF (any(var(i)%btable == delete_attr(:))) THEN ! n.b. ANY((//)) = .FALSE.
1709 var(i) = vol7d_var_miss
1710 ENDIF
1711 ENDDO
1712 end if
1713ENDIF
1714
1715END SUBROUTINE delete_var
1716
1717END SUBROUTINE vol7d_peeling
1718
1719
1720end module modqc
Variables user in Quality Control.
Definition modqc.F90:386
Test di dato invalidato.
Definition modqc.F90:411
Remove data under a defined grade of confidence.
Definition modqc.F90:391
Check data validity based on single confidence.
Definition modqc.F90:401
Check data validity based on gross error check.
Definition modqc.F90:406
Definition of constants to be used for declaring variables of a desired type.
Definition kinds.F90:245
Definitions of constants and functions for working with missing values.
Utilities and defines for quality control.
Definition modqc.F90:357
Module for quickly interpreting the OPTIONAL parameters passed to a subprogram.
Classe per la gestione di un volume completo di dati osservati.
Definisce il livello di attendibilità per i dati validi.
Definition modqc.F90:368

Generated with Doxygen.