source: trunk/src/join_dmean_asc.pro @ 5

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

draft of output files

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