"BEST1EXP",
"RAND1EXP",
"RANDTOBEST1EXP",
- "CURRENTTOBEST1EXP",
"BEST2EXP",
"RAND2EXP",
"RANDTOBEST1BIN",
- "CURRENTTOBEST1BIN",
"BEST2BIN",
"RAND2BIN",
"RAND1BIN".
"BEST1EXP",
"RAND1EXP",
"RANDTOBEST1EXP",
- "CURRENTTOBEST1EXP",
"BEST2EXP",
"RAND2EXP",
"RANDTOBEST1BIN",
- "CURRENTTOBEST1BIN",
"BEST2BIN",
"RAND2BIN",
"RAND1BIN".
try:
# Create Assimilation study
+ import adao
from daYacsIntegration.daStudy import *
assim_study = daStudy(Name, Algorithm, Debug)
"BEST1EXP",
"RAND1EXP",
"RANDTOBEST1EXP",
- "CURRENTTOBEST1EXP",
+ # "CURRENTTOBEST1EXP",
"BEST2EXP",
"RAND2EXP",
"RANDTOBEST1BIN",
- "CURRENTTOBEST1BIN",
+ # "CURRENTTOBEST1BIN",
"BEST2BIN",
"RAND2BIN",
"RAND1BIN",
AppliedInXb = None,
AvoidRC = True,
Checked = False,
+ ColMajor = False,
+ ColNames = None,
+ DataFile = None,
DiagonalSparseMatrix = None,
Info = None,
Matrix = None,
try:
if Concept in ("Background", "CheckingPoint", "ControlInput", "Observation"):
commande = getattr(self,"set"+Concept)
- commande(Vector, VectorSerie, Script, Stored, Scheduler, Checked )
+ commande(Vector, VectorSerie, Script, DataFile, ColNames, ColMajor, Stored, Scheduler, Checked )
elif Concept in ("BackgroundError", "ObservationError", "EvolutionError"):
commande = getattr(self,"set"+Concept)
commande(Matrix, ScalarSparseMatrix, DiagonalSparseMatrix,
Vector = None,
VectorSerie = None,
Script = None,
+ DataFile = None,
+ ColNames = None,
+ ColMajor = False,
Stored = False,
Scheduler = None,
Checked = False):
asVector = Vector,
asPersistentVector = VectorSerie,
asScript = self.__with_directory(Script),
+ asDataFile = DataFile,
+ colNames = ColNames,
+ colMajor = ColMajor,
scheduledBy = Scheduler,
toBeChecked = Checked,
)
Vector = None,
VectorSerie = None,
Script = None,
+ DataFile = None,
+ ColNames = None,
+ ColMajor = False,
Stored = False,
Scheduler = None,
Checked = False):
asVector = Vector,
asPersistentVector = VectorSerie,
asScript = self.__with_directory(Script),
+ asDataFile = DataFile,
+ colNames = ColNames,
+ colMajor = ColMajor,
scheduledBy = Scheduler,
toBeChecked = Checked,
)
Vector = None,
VectorSerie = None,
Script = None,
+ DataFile = None,
+ ColNames = None,
+ ColMajor = False,
Stored = False,
Scheduler = None,
Checked = False):
asVector = Vector,
asPersistentVector = VectorSerie,
asScript = self.__with_directory(Script),
+ asDataFile = DataFile,
+ colNames = ColNames,
+ colMajor = ColMajor,
scheduledBy = Scheduler,
toBeChecked = Checked,
)
Vector = None,
VectorSerie = None,
Script = None,
+ DataFile = None,
+ ColNames = None,
+ ColMajor = False,
Stored = False,
Scheduler = None,
Checked = False):
asVector = Vector,
asPersistentVector = VectorSerie,
asScript = self.__with_directory(Script),
+ asDataFile = DataFile,
+ colNames = ColNames,
+ colMajor = ColMajor,
scheduledBy = Scheduler,
toBeChecked = Checked,
)
from daCore import PlatformInfo
from daCore import Interfaces
from daCore import Templates
-from daCore.Interfaces import ImportFromScript
+from daCore.Interfaces import ImportFromScript, ImportFromFile
# ==============================================================================
class CacheManager(object):
asVector = None,
asPersistentVector = None,
asScript = None,
+ asDataFile = None,
+ colNames = None,
+ colMajor = False,
scheduledBy = None,
toBeChecked = False,
):
nommée "name", la variable est de type "asVector" (par défaut) ou
"asPersistentVector" selon que l'une de ces variables est placée à
"True".
+ - asDataFile : si un ou plusieurs fichiers valides sont donnés
+ contenant des valeurs en colonnes, elles-mêmes nommées "colNames"
+ (s'il n'y a pas de nom de colonne indiquée, on cherche une colonne
+ nommée "name"), on récupère les colonnes et on les range ligne après
+ ligne (colMajor=False) ou colonne après colonne (colMajor=True). La
+ variable résultante est de type "asVector" (par défaut) ou
+ "asPersistentVector" selon que l'une de ces variables est placée à
+ "True".
"""
self.__name = str(name)
self.__check = bool(toBeChecked)
__Series = ImportFromScript(asScript).getvalue( self.__name )
else:
__Vector = ImportFromScript(asScript).getvalue( self.__name )
+ elif asDataFile is not None:
+ __Vector, __Series = None, None
+ if asPersistentVector:
+ if colNames is not None:
+ __Series = ImportFromFile(asDataFile).getvalue( colNames )[1]
+ else:
+ __Series = ImportFromFile(asDataFile).getvalue( [self.__name,] )[1]
+ if bool(colMajor) and not ImportFromFile(asDataFile).getformat() == "application/numpy.npz":
+ __Series = numpy.transpose(__Series)
+ elif not bool(colMajor) and ImportFromFile(asDataFile).getformat() == "application/numpy.npz":
+ __Series = numpy.transpose(__Series)
+ else:
+ if colNames is not None:
+ __Vector = ImportFromFile(asDataFile).getvalue( colNames )[1]
+ else:
+ __Vector = ImportFromFile(asDataFile).getvalue( [self.__name,] )[1]
+ if bool(colMajor):
+ __Vector = numpy.ravel(__Vector, order = "F")
+ else:
+ __Vector = numpy.ravel(__Vector, order = "C")
else:
__Vector, __Series = asVector, asPersistentVector
#
for k in __keys:
__v = __local[k]
if __v is None: continue
- if k == "Checked" and not __v: continue
- if k == "Stored" and not __v: continue
- if k == "AvoidRC" and __v: continue
+ if k == "Checked" and not __v: continue
+ if k == "Stored" and not __v: continue
+ if k == "ColMajor" and not __v: continue
+ if k == "AvoidRC" and __v: continue
if k == "noDetails": continue
if isinstance(__v,Persistence.Persistence): __v = __v.values()
if callable(__v): __text = self._missing%__v.__name__+__text
__text += "%s_config['From'] = '%s'\n"%(__command,__f)
__text += "%s_config['Data'] = %s\n"%(__command,__v)
__text = __text.replace("''","'")
- elif __k in ('Stored', 'Checked'):
+ elif __k in ('Stored', 'Checked', 'ColMajor'):
if bool(__v):
__text += "%s_config['%s'] = '%s'\n"%(__command,__k,int(bool(__v)))
elif __k in ('AvoidRC', 'noDetails'):
self.__header, self._varsline, self._skiprows = self.__getentete()
#
if self._format == "text/csv" or Format.upper() == "CSV":
+ self._format = "text/csv"
self.__filestring = "".join(self.__header)
if self.__filestring.count(",") > 1:
self._delimiter = ","
elif self.__filestring.count(";") > 1:
self._delimiter = ";"
elif self._format == "text/tab-separated-values" or Format.upper() == "TSV":
+ self._format = "text/tab-separated-values"
self._delimiter = "\t"
else:
self._delimiter = None
__index = numpy.loadtxt(self._filename, dtype = bytes, usecols = (__useindex,), delimiter = self._delimiter, skiprows=self._skiprows)
else:
raise ValueError("Unkown file format \"%s\""%self._format)
+ if __columns is None: __columns = ()
#
def toString(value):
try:
with open(self._filename,'r') as fid:
return fid.read()
+ def getformat(self):
+ return self._format
+
# ==============================================================================
class ImportScalarLinesFromFile(ImportFromFile):
"""