Bonjour,
Je tente de lire un fichier de données météo sur eclipse. Voici le code :
En réponse j'obtient :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72 import java.io.FileNotFoundException; import java.io.IOException; import java.util.NoSuchElementException; import net.sourceforge.jgrib.*; public class Essai { public void main(String[] args){ GribFile grb = null; try { grb = new GribFile("EastAtlantic.wind.grb"); } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } catch (NotSupportedException e1) { e1.printStackTrace(); } catch (NoValidGribException e1) { e1.printStackTrace(); } GribRecordGDS r2=grb.getGrids()[0]; GribRecord ventU = null; try { ventU = grb.getRecord(1); } catch (NoSuchElementException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } catch (NoValidGribException e1) { e1.printStackTrace(); } catch (NotSupportedException e1) { e1.printStackTrace(); } GribRecord ventV = null; try { ventV = grb.getRecord(2); } catch (NoSuchElementException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } catch (NoValidGribException e1) { e1.printStackTrace(); } catch (NotSupportedException e1) { e1.printStackTrace(); } int nbx = r2.getGridNX(); int nby = r2.getGridNY(); for (int i=0 ; i<nbx ; i++) { for (int j=0 ; j<nby ; j++) { // affichage des la donnee (i,j) try { System.out.print(ventU.getValue(i, j)+" "); } catch (NoValidGribException e) { // TODO Auto-generated catch block e.printStackTrace(); } } System.out.println(); } // affichage de l'unite des donnees System.out.println(ventV.getUnit()); // description de la donnee System.out.println(ventU.getPDS()); } }
Je suis donc parti à la découverte de log4j, avec succès. Malheureusement les informations recueillies ne m'ont pas permis de comprendre et de maîtriser l'utilisation de cette fonction.Gribfile: EastAtlantic.wind.grb
log4j:WARN No appenders could be found for logger (net.sourceforge.jgrib.BitInputStream).
log4j:WARN Please initialize the log4j system properly.
Records: 122
Grid:
GDS section:
LatLon Grid (36x53)
lon: -43.75 to -0.151 (dx 1.25)
lat: 62.0 to 10.331 (dy -1.0)
mode(17):0x80
type(6) :0x0
scan(28):0x0
PDS cent sub tab proc: 7 0 2 88
-> cent sub tab file: 7 -1 2 ncep_reanal2.2
Z type(1): surface
Dates(61) delta[3.0hr]:
min Sun Feb 27 07:00:00 CET 2011
max Sun Mar 06 19:00:00 CET 2011
Param: 33 ugrd [m/s] u wind [-9.9 19.22]
Param: 34 vgrd [m/s] v wind [-15.93 14.469999]
Je demande donc votre aide pour faire disparaître les 'WARN' pour obtenir mes données.
Bonne journée,
Geoffrey
Partager