Commit 7eef0bac authored by caveenj's avatar caveenj

Modifier odf2csv pour que la moyenne ne soit pas calculee automatiquement

Correction d'un bogue lors du moyennage ou on traitait les QQQQ ou QFFF pour les
moyennes
Ajout du fichier setup.py servant a faire une distribution (setup.py bdist)
parent 9c3dc88c
......@@ -6,5 +6,5 @@ cd ../test_data
for ficin in *.ODF
do
ficout=`basename ${ficin} .ODF`
../src/odf2csv.py -i ${ficin} -o ${ficout}_all.csv --all
../src/odf2csv.py -i ${ficin} -o ${ficout}all.csv
done
#!/bin/sh
#Convertir tous les fichiers odf en conservant
# toutes les donnees
#Convertir tous les fichiers odf en
#moyennant au 10 metres en eliminitant douteux et erreurs
cd ../test_data
for ficin in *.ODF
do
ficout=`basename ${ficin} .ODF`
../src/odf2csv.py -i ${ficin} -o ${ficout}_mean.csv --mean 10
../src/odf2csv.py -i ${ficin} -o ${ficout}mean.csv --doubtfull --error --mean 10
done
#!/usr/bin/env python
#! python
#####################################
#
......@@ -17,18 +18,18 @@ import math
from class_variable import variable
import odf_fcns
RemplacerDouteux = True
RemplacerErreur = True
CalculerMoyenne = True
RemplacerDouteux = False
RemplacerErreur = False
CalculerMoyenne = False
intervalle = 1.0
#On recupere les parametres d'appel
try:
opts,args = getopt.getopt(sys.argv[1:], \
'i:o:m:deah',\
'i:o:m:deh',\
['input=','output=',\
'mean=','all','error',\
'douteux','help'])
'mean=','error',\
'doubtfull','help'])
except getopt.error, msg:
print msg
odf_fcns.usage()
......@@ -42,35 +43,31 @@ for o , a in opts:
elif o in ("-i","--input"):
if a in ("-i","--input","-o","--output","-d",\
"--douteux","-e","--error","-h","--help","--mean","-m",\
"-a","--all"):
"--doubtfull","-e","--error","-h","--help","--mean","-m"):
odf_fcns.usage()
sys.exit(2)
fnomin = a
elif o in ("-o","--output"):
if a in ("-i","--input","-o","--output","-d",\
"--douteux","-e","--error","-h","--help","--mean","-m",\
"-a","--all"):
"--doubtfull","-e","--error","-h","--help","--mean","-m"):
odf_fcns.usage()
sys.exit(2)
fnomout = a
elif o in ("-m","--mean"):
if a in ("-i","--input","-o","--output","-d",\
"--douteux","-e","--error","-h","--help","--mean","-m",\
"-a","--all"):
"--doubtfull","-e","--error","-h","--help","--mean","-m"):
odf_fcns.usage()
sys.exit(2)
intervalle = float(a)
CalculerMoyenne = True
elif o in ("-d","--douteux"):
RemplacerDouteux = False
elif o in ("-d","--doubtfull"):
RemplacerDouteux = True
elif o in ("-e","--error"):
RemplacerErreur = False
elif o in ("-a","--all"):
CalculerMoyenne = False
RemplacerErreur = True
else:
print "Option inconnue"
odf_fcns.usage()
......@@ -354,34 +351,40 @@ if (CalculerMoyenne):
# Ici, on traite toutes les variables sauf PRES et DEPTH
for var in varlist:
if not DEPTH.search(var.getcode()) and not PRES.search(var.getcode()):
if not DEPTH.search(var.getcode()) and not PRES.search(var.getcode()) and \
not QCFF.search(var.getcode()) and not QQQQ.search(var.getcode()):
print "On traite:", var.getcode()
if(var_q.has_key(var)):
qualite = var_q.get(var)
mean_dat = []
qualite_dat = []
for k in range(num_depth):
sum_dat=0
n_dat=0
for i in range(var.getnbval()):
if float(profondeur.getvaleur(i)) > (depth[k]-intervalle/2.0) and \
float(profondeur.getvaleur(i)) <= (depth[k]+intervalle/2.0) and \
float(var.getvaleur(i)) > -99 :
sum_dat=sum_dat+ float(var.getvaleur(i))
n_dat=n_dat+1
if n_dat == 0 :
mean_dat.append(-99.0)
else:
mean_dat.append(sum_dat/n_dat)
mean_dat = []
for k in range(num_depth):
sum_dat=0
n_dat=0
for i in range(var.getnbval()):
if float(profondeur.getvaleur(i)) > (depth[k]-intervalle/2.0) and \
float(profondeur.getvaleur(i)) <= (depth[k]+intervalle/2.0) and \
float(var.getvaleur(i)) > -99 :
sum_dat=sum_dat+ float(var.getvaleur(i))
n_dat=n_dat+1
if n_dat == 0 :
mean_dat.append(-99.0)
else:
mean_dat.append(sum_dat/n_dat)
if(var_q.has_key(var)):
if mean_dat[k] == -99:
qualite_dat.append(9)
elif mean_dat[k] > -99:
qualite_dat.append(1)
var.replaceallvaleurs(mean_dat)
var.replaceallvaleurs(mean_dat)
if(var_q.has_key(var)):
qualite.replaceallvaleurs(qualite_dat)
......@@ -391,31 +394,35 @@ if (CalculerMoyenne):
print "On traite:", var.getcode()
if(var_q.has_key(var)):
qualite = var_q.get(var)
mean_dat = []
qualite_dat = []
for k in range(num_depth):
sum_dat=0
n_dat=0
for i in range(var.getnbval()):
if DEPTH.search(var.getcode()):
sum_dat=sum_dat+depth[k]
n_dat=n_dat+1
elif PRES.search(var.getcode()):
sum_dat=sum_dat+odf_fcns.depth2pres(depth[k],float(init_lat))
n_dat=n_dat+1
if n_dat == 0 :
mean_dat.append(-99.0)
else:
mean_dat.append(sum_dat/n_dat)
mean_dat = []
for k in range(num_depth):
sum_dat=0
n_dat=0
for i in range(var.getnbval()):
if DEPTH.search(var.getcode()):
sum_dat=sum_dat+depth[k]
n_dat=n_dat+1
elif PRES.search(var.getcode()):
sum_dat=sum_dat+odf_fcns.depth2pres(depth[k],float(init_lat))
n_dat=n_dat+1
if n_dat == 0 :
mean_dat.append(-99.0)
else:
mean_dat.append(sum_dat/n_dat)
if(var_q.has_key(var)):
if mean_dat[k] == -99:
qualite_dat.append(9)
elif mean_dat[k] > -99:
qualite_dat.append(1)
var.replaceallvaleurs(mean_dat)
var.replaceallvaleurs(mean_dat)
if(var_q.has_key(var)):
qualite.replaceallvaleurs(qualite_dat)
......@@ -485,9 +492,11 @@ fout.write(chaine)
for i in range(varlist[0].getnbval()):
chaine =''
for var in varlist:
print "var = ", var.getcode()
if CalculerMoyenne and QCFF.search(var.getcode()):
pass
else:
print "i = ", i
chaine = chaine + var.getvaleur(i) + '\t'
chaine = chaine + '\n'
fout.write(chaine)
......
......@@ -56,10 +56,8 @@ def usage():
print "ficout: fichier sortie (output file"
print "interval : intervale de profondeurs pour donnees moyennees"
print " (depth interval for mean data)"
print "-a : toutes les donnees : ne pas moyenner"
print " (all data : do not average)"
print "-d : conserver donnees douteuses (keep data flaged as doubtfull)"
print "-e : conserver donnees erronnees (keep data flaged as erroneous)"
print "-d : eliminer donnees douteuses (discard data flaged as doubtfull)"
print "-e : eliminer donnees erronnees (discard data flaged as erroneous)"
from distutils.core import setup
auteur = "James Caveen"
nom="odf2csv"
ver="1.0"
modules = ["class_variable","odf_fcns"]
script = ["odf2csv.py"]
setup(name=nom,author=auteur,version=ver,py_modules = modules,scripts=script)
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment