source: trunk/src/join_dmean_asc.pro @ 14

Last change on this file since 14 was 14, checked in by pinsard, 10 years ago

fix thanks to coding rules; utf8

  • Property svn:keywords set to Id
File size: 4.1 KB
Line 
1;+
2;
3; ==================
4; join_dmean_asc.pro
5; ==================
6;
7; .. function:: join_dmean_asc(data_dmean,data_asc)
8;
9;    Join information from mean (++details) and asc (++detail) structures
10;
11;    If station is not found in data_asc structure, latitude and longitude
12;    are set to NaN.
13;
14;    :param data_dmean: structure ++details
15;    :type data_dmean: structure
16;    :raise data_dmean: required
17;
18;    :param data_asc: structure ++details
19;    :type data_asc: structure
20;    :raise data_asc: required
21;
22;    :returns: data structure +todo+ details or -1 if error
23;    :rtype: structure +todo+ details
24;
25; :examples:
26;
27; Realistic example with POMME files:
28;
29; .. code-block:: idl
30;
31;    data_asc = file_asc_to_mem()
32;    data_prn = file_prn_to_mem()
33;    data_dmean = dmean_mld(data_prn)
34;    data_insitu = join_dmean_asc(data_dmean,data_asc)
35;
36; impression de controle :
37;
38; .. code-block:: idl
39;
40;    help, data_insitu, /structure
41;    print, data_insitu[0]
42;    print, data_insitu.lat
43;    print, data_insitu.lon
44;
45; :uses:
46;
47;
48; :func:`report <saxo:report>`
49;
50; :see also:
51;
52; :func:`file_prn_to_mem`
53; :func:`file_asc_to_mem`
54; :func:`dmean_mld`
55;
56; :restrictions:
57;
58; :todo:
59;
60; test arguments
61;
62; missing values
63;
64; usage of report
65;
66; init returned structure to NaN vs 0L or 0.0
67;
68; check doy in prn files vs computed julianday
69; now (20101124) differences due to either bad calculation here or bad
70; doy calculation in .prn file or difference choice between begin, end,
71; middle time.
72;
73; :history:
74;
75; - fplod 20101129T133140Z aedon.locean-ipsl.upmc.fr (Darwin)
76;
77;   * correction for NaN
78;   * suppression print controle
79;
80; - fplod 20101129T091703Z aedon.locean-ipsl.upmc.fr (Darwin)
81;
82;   * input data_dmean instead of data_prn
83;
84; - fplod 20101126T153732Z aedon.locean-ipsl.upmc.fr (Darwin)
85;
86;   * input = structures no more files
87;
88; - fplod 20101123T154451Z aedon.locean-ipsl.upmc.fr (Darwin)
89;
90;   * creation
91;
92; :version:
93;
94; $Id$
95;
96;-
97FUNCTION join_dmean_asc, data_dmean, data_asc
98    ;
99    compile_opt idl2, strictarrsubs
100    ;
101    ; Return to caller if errors
102    ON_ERROR, 2
103    ;
104    usage = 'result = join_dmean_asc(data_asc,data_dmean)'
105    ;
106    nparam = N_PARAMS()
107    IF (nparam LT 2) THEN BEGIN
108        ras = report(['Incorrect number of arguments.' $
109        + '!C' $
110        + 'Usage : ' + usage])
111        return, -1
112    ENDIF
113    ;
114    ; initialize returned structure
115    resultstruct = { doy : 0L $
116    , lat: 0.0 $
117    , lon: 0.0 $
118    , mean_zhom001: 0.0 $
119    , mean_zhom002 : 0.0 $
120    , mean_zhom005 : 0.0 $
121    , mean_zhom010: 0.0 $
122    , mean_zhomelch : 0.0 $
123    , std_zhom001: 0.0 $
124    , std_zhom002 : 0.0 $
125    , std_zhom005 : 0.0 $
126    , std_zhom010: 0.0 $
127    , std_zhomelch : 0.0 $
128    }
129    ;
130    ndays = n_elements(data_dmean)
131    result = replicate(resultstruct, ndays)
132    ;
133    ; fill returned structure
134    FOR iday = 0L, ndays - 1 DO BEGIN
135        result[iday].doy = data_dmean[iday].doy
136        result[iday].mean_zhom001 = data_dmean[iday].mean_zhom001
137        result[iday].mean_zhom002 = data_dmean[iday].mean_zhom002
138        result[iday].mean_zhom005 = data_dmean[iday].mean_zhom005
139        result[iday].mean_zhom010 = data_dmean[iday].mean_zhom010
140        result[iday].mean_zhomelch = data_dmean[iday].mean_zhomelch
141        result[iday].std_zhom001 = data_dmean[iday].std_zhom001
142        result[iday].std_zhom002 = data_dmean[iday].std_zhom002
143        result[iday].std_zhom005 = data_dmean[iday].std_zhom005
144        result[iday].std_zhom010 = data_dmean[iday].std_zhom010
145        result[iday].std_zhomelch = data_dmean[iday].std_zhomelch
146        indice_asc = WHERE(data_asc.station EQ data_dmean[iday].first_station,count)
147        IF (count EQ 0) THEN BEGIN
148            print, 'no station ',  data_dmean[iday].first_station,' in data_asc.station'
149            result[iday].lat = !VALUES.F_NAN
150            result[iday].lon = !VALUES.F_NAN
151        ENDIF ELSE BEGIN
152            ;print, 'indice de la first_station', data_dmean[iday].first_station,' dans data_asc = ',indice_asc
153            result[iday].lat = data_asc[indice_asc[0]].lat
154            result[iday].lon = data_asc[indice_asc[0]].lon
155        ENDELSE
156    ENDFOR
157    ;
158    return, result
159    ;
160END
Note: See TracBrowser for help on using the repository browser.