mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
update nc file writing functions
This commit is contained in:
parent
a0c0fc86b3
commit
81756e9dce
@ -84,6 +84,7 @@ public class NCUtil {
|
|||||||
ncArray = (ucar.ma2.Array)((ArrayStructure)array).getArrayObject();
|
ncArray = (ucar.ma2.Array)((ArrayStructure)array).getArrayObject();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
array = array.copyIfView();
|
||||||
ncArray = ucar.ma2.Array.factory(convertDataType(array.getDataType()), array.getShape(), array.getStorage());
|
ncArray = ucar.ma2.Array.factory(convertDataType(array.getDataType()), array.getShape(), array.getStorage());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,32 +1,34 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\scatter">
|
<Path OpenPath="D:\Working\MIScript\cuace_dust\py\mm5">
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\test"/>
|
|
||||||
<RecentFolder Folder="D:\Temp\script"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\interpolate"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\data_process"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\data_process"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\grads"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\grads"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\math"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\math"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo\interpolation"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo\interpolation"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite\calipso"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite\calipso"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\scatter"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\scatter"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\ascii"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\array"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\cuace_dust\py\mm5"/>
|
||||||
</Path>
|
</Path>
|
||||||
<File>
|
<File>
|
||||||
<OpenedFiles>
|
<OpenedFiles>
|
||||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\cluster\dbscan_1.py"/>
|
<OpenedFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\cluster\dbscan_1.py"/>
|
||||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\deep_learning\convolution\mnist_cnn.py"/>
|
<OpenedFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\deep_learning\convolution\mnist_cnn.py"/>
|
||||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\scatter\scatter_density.py"/>
|
<OpenedFile File="D:\Working\MIScript\cuace_dust\py\mm5\mm5tonc_lcc.py"/>
|
||||||
|
<OpenedFile File="D:\Working\MIScript\cuace_dust\py\mm5\test_nc-2.py"/>
|
||||||
</OpenedFiles>
|
</OpenedFiles>
|
||||||
<RecentFiles>
|
<RecentFiles>
|
||||||
<RecentFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\cluster\dbscan_1.py"/>
|
<RecentFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\cluster\dbscan_1.py"/>
|
||||||
<RecentFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\deep_learning\convolution\mnist_cnn.py"/>
|
<RecentFile File="D:\Working\MIScript\Jython\mis\toolbox\miml\deep_learning\convolution\mnist_cnn.py"/>
|
||||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\scatter\scatter_density.py"/>
|
<RecentFile File="D:\Working\MIScript\cuace_dust\py\mm5\mm5tonc_lcc.py"/>
|
||||||
|
<RecentFile File="D:\Working\MIScript\cuace_dust\py\mm5\test_nc-2.py"/>
|
||||||
</RecentFiles>
|
</RecentFiles>
|
||||||
</File>
|
</File>
|
||||||
<Font>
|
<Font>
|
||||||
@ -34,5 +36,5 @@
|
|||||||
</Font>
|
</Font>
|
||||||
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
|
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
|
||||||
<Figure DoubleBuffering="true"/>
|
<Figure DoubleBuffering="true"/>
|
||||||
<Startup MainFormLocation="-7,0" MainFormSize="1442,851"/>
|
<Startup MainFormLocation="-7,-7" MainFormSize="1293,693"/>
|
||||||
</MeteoInfo>
|
</MeteoInfo>
|
||||||
|
|||||||
Binary file not shown.
@ -363,13 +363,17 @@ class DimDataFile(object):
|
|||||||
:param attrs: (*dict*) Attributes.
|
:param attrs: (*dict*) Attributes.
|
||||||
'''
|
'''
|
||||||
dt = self.__getdatatype(datatype)
|
dt = self.__getdatatype(datatype)
|
||||||
if isinstance(dims[0], Dimension):
|
if len(dims) > 0:
|
||||||
ncdims = []
|
if isinstance(dims[0], Dimension):
|
||||||
for dim in dims:
|
ncdims = []
|
||||||
ncdims.append(self.ncfile.findDimension(dim.getName()))
|
for dim in dims:
|
||||||
var = DimVariable(ncvariable=self.ncfile.addVariable(group, varname, dt, ncdims))
|
ncdims.append(self.ncfile.findDimension(dim.getName()))
|
||||||
|
var = DimVariable(ncvariable=self.ncfile.addVariable(group, varname, dt, ncdims))
|
||||||
|
else:
|
||||||
|
var = DimVariable(ncvariable=self.ncfile.addVariable(group, varname, dt, dims))
|
||||||
else:
|
else:
|
||||||
var = DimVariable(ncvariable=self.ncfile.addVariable(group, varname, dt, dims))
|
var = DimVariable(ncvariable=self.ncfile.addVariable(group, varname, dt, dims))
|
||||||
|
|
||||||
if not attrs is None:
|
if not attrs is None:
|
||||||
for key in attrs:
|
for key in attrs:
|
||||||
var.addattr(key, attrs[key])
|
var.addattr(key, attrs[key])
|
||||||
|
|||||||
Binary file not shown.
@ -60,7 +60,10 @@ class DimVariable(object):
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.variable is None:
|
if self.variable is None:
|
||||||
return 'None'
|
if self.ncvariable is None:
|
||||||
|
return 'None'
|
||||||
|
else:
|
||||||
|
return self.ncvariable.toString()
|
||||||
|
|
||||||
r = str(self.dtype) + ' ' + self.name + '('
|
r = str(self.dtype) + ' ' + self.name + '('
|
||||||
for dim in self.dims:
|
for dim in self.dims:
|
||||||
|
|||||||
Binary file not shown.
@ -485,7 +485,8 @@ def readtable(filename, **kwargs):
|
|||||||
:param headerlines: (*int*) Lines to skip at beginning of the file. Default is ``0``. The line
|
:param headerlines: (*int*) Lines to skip at beginning of the file. Default is ``0``. The line
|
||||||
after the skip lines will be read as variable names of the table. the ``headerlines`` should set
|
after the skip lines will be read as variable names of the table. the ``headerlines`` should set
|
||||||
as ``-1`` if there is no field name line at beginning of the file.
|
as ``-1`` if there is no field name line at beginning of the file.
|
||||||
:param encoding: (*string*) Character encoding scheme associated with the file. Default is ``UTF8``.
|
:param encoding: (*string*) Character encoding scheme associated with the file. Default is ``None`` that the function
|
||||||
|
will check the encoding automatically.
|
||||||
:param varnames: (*string*) Specified variable names for the readed table. Default is ``None``, means
|
:param varnames: (*string*) Specified variable names for the readed table. Default is ``None``, means
|
||||||
the variable names should be read from the file.
|
the variable names should be read from the file.
|
||||||
:param readvarnames: (*boolean*) Read variable names or not. Default is ``True``.
|
:param readvarnames: (*boolean*) Read variable names or not. Default is ``True``.
|
||||||
@ -500,7 +501,7 @@ def readtable(filename, **kwargs):
|
|||||||
delimiter = kwargs.pop('delimiter', None)
|
delimiter = kwargs.pop('delimiter', None)
|
||||||
format = kwargs.pop('format', None)
|
format = kwargs.pop('format', None)
|
||||||
headerlines = kwargs.pop('headerlines', 0)
|
headerlines = kwargs.pop('headerlines', 0)
|
||||||
encoding = kwargs.pop('encoding', 'UTF8')
|
encoding = kwargs.pop('encoding', None)
|
||||||
readvarnames = kwargs.pop('readvarnames', True)
|
readvarnames = kwargs.pop('readvarnames', True)
|
||||||
readrownames = kwargs.pop('readrownames', False)
|
readrownames = kwargs.pop('readrownames', False)
|
||||||
usecols = kwargs.pop('usecols', None)
|
usecols = kwargs.pop('usecols', None)
|
||||||
|
|||||||
@ -483,6 +483,7 @@ class NDArray(object):
|
|||||||
"""
|
"""
|
||||||
provide iteration over the values of the array
|
provide iteration over the values of the array
|
||||||
"""
|
"""
|
||||||
|
self.iterator = self._array.getIndexIterator()
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def next(self):
|
def next(self):
|
||||||
|
|||||||
@ -366,7 +366,7 @@ public class Index implements Cloneable {
|
|||||||
Index reshape(int[] shape) {
|
Index reshape(int[] shape) {
|
||||||
boolean canReshape = true;
|
boolean canReshape = true;
|
||||||
for (int s : this.stride) {
|
for (int s : this.stride) {
|
||||||
if (s > 1) {
|
if (s != 1) {
|
||||||
canReshape = false;
|
canReshape = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1516,20 +1516,18 @@ public class ArrayUtil {
|
|||||||
for (int i = 0; i < ndim; i++) {
|
for (int i = 0; i < ndim; i++) {
|
||||||
r.add(new ArrayList<Integer>());
|
r.add(new ArrayList<Integer>());
|
||||||
}
|
}
|
||||||
Index index = a.getIndex();
|
|
||||||
IndexIterator iterA = a.getIndexIterator();
|
IndexIterator iterA = a.getIndexIterator();
|
||||||
int[] counter;
|
int[] counter;
|
||||||
double v;
|
double v;
|
||||||
while (iterA.hasNext()) {
|
while (iterA.hasNext()) {
|
||||||
v = iterA.getDoubleNext();
|
v = iterA.getDoubleNext();
|
||||||
if (!Double.isNaN(v) && v != 0) {
|
if (!Double.isNaN(v) && v != 0) {
|
||||||
counter = index.getCurrentCounter();
|
counter = iterA.getCurrentCounter();
|
||||||
for (int j = 0; j < ndim; j++) {
|
for (int j = 0; j < ndim; j++) {
|
||||||
r.get(j).add(counter[j]);
|
r.get(j).add(counter[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
index.incr();
|
|
||||||
//iterA.next();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r.get(0).isEmpty()) {
|
if (r.get(0).isEmpty()) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user