debug
This commit is contained in:
parent
d0d90f8f7d
commit
2ab03678bf
@ -142,7 +142,7 @@ class ImageAnalyser():
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
dataSet[self._image_name['OD']].attrs.update(dataSet.attrs)
|
# dataSet[self._image_name['OD']].attrs.update(dataSet.attrs)
|
||||||
|
|
||||||
return dataSet
|
return dataSet
|
||||||
|
|
||||||
|
@ -61,6 +61,15 @@ class MongoDB:
|
|||||||
if not date is None:
|
if not date is None:
|
||||||
self.set_date(date)
|
self.set_date(date)
|
||||||
|
|
||||||
|
data = {
|
||||||
|
'year': self.year,
|
||||||
|
'month': self.month,
|
||||||
|
'day': self.day,
|
||||||
|
'shotNum': shotNum,
|
||||||
|
}
|
||||||
|
|
||||||
|
self.mongoDB['global'].delete_many(data)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'year': self.year,
|
'year': self.year,
|
||||||
'month': self.month,
|
'month': self.month,
|
||||||
@ -91,6 +100,11 @@ class MongoDB:
|
|||||||
)
|
)
|
||||||
|
|
||||||
stackedDataArray = self._break_dataSet(dataSet)
|
stackedDataArray = self._break_dataSet(dataSet)
|
||||||
|
try:
|
||||||
|
stackedDataArray.load()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
stackedDataArray = stackedDataArray.groupby('_scanAxis')
|
stackedDataArray = stackedDataArray.groupby('_scanAxis')
|
||||||
|
|
||||||
for i in stackedDataArray:
|
for i in stackedDataArray:
|
||||||
@ -133,7 +147,7 @@ class MongoDB:
|
|||||||
|
|
||||||
self.mongoDB['global'].update_one(filter, {"$set": data}, upsert=False)
|
self.mongoDB['global'].update_one(filter, {"$set": data}, upsert=False)
|
||||||
|
|
||||||
def _add_data_xarray_dataArray(self, shotNum, dataArray, scanAxis=None):
|
def _add_data_xarray_dataArray(self, shotNum, dataArray, name=None, scanAxis=None):
|
||||||
|
|
||||||
if scanAxis is None:
|
if scanAxis is None:
|
||||||
scanAxis = list(dataArray.coords)
|
scanAxis = list(dataArray.coords)
|
||||||
@ -255,9 +269,9 @@ class MongoDB:
|
|||||||
self._add_data_normal(shotNum=shotNum, runNum=runNum, data=data)
|
self._add_data_normal(shotNum=shotNum, runNum=runNum, data=data)
|
||||||
elif engine == 'xarray':
|
elif engine == 'xarray':
|
||||||
if isinstance(data, type(xr.Dataset())):
|
if isinstance(data, type(xr.Dataset())):
|
||||||
self._add_data_xarray_dataSet(shotNum=shotNum, data=data, name=name)
|
self._add_data_xarray_dataSet(shotNum=shotNum, dataSet=data, name=name)
|
||||||
else:
|
else:
|
||||||
self._add_data_xarray_dataArray(shotNum=shotNum, data=data, name=name)
|
self._add_data_xarray_dataArray(shotNum=shotNum, dataArray=data, name=name)
|
||||||
elif engine == 'additional':
|
elif engine == 'additional':
|
||||||
self._add_data_additional(shotNum=shotNum, runNum=runNum, data=data, name=name)
|
self._add_data_additional(shotNum=shotNum, runNum=runNum, data=data, name=name)
|
||||||
|
|
||||||
@ -293,11 +307,12 @@ class MongoDB:
|
|||||||
result = {}
|
result = {}
|
||||||
dropped_attrs = OrderedDict()
|
dropped_attrs = OrderedDict()
|
||||||
|
|
||||||
docs = self.mongoDB['global'].find(filter)
|
docs = self.mongoDB['global'].find(filter).sort('runNum')
|
||||||
|
docs = [doc['global_parameters'] for doc in docs]
|
||||||
|
|
||||||
for doc in docs:
|
for doc in docs:
|
||||||
|
|
||||||
global_parameters = doc['global_parameters']
|
global_parameters = doc
|
||||||
|
|
||||||
result.update(
|
result.update(
|
||||||
{
|
{
|
||||||
@ -322,7 +337,7 @@ class MongoDB:
|
|||||||
|
|
||||||
for doc in docs:
|
for doc in docs:
|
||||||
|
|
||||||
global_parameters = doc['global_parameters']
|
global_parameters = doc
|
||||||
|
|
||||||
dropped_attrs.update(
|
dropped_attrs.update(
|
||||||
{
|
{
|
||||||
@ -333,20 +348,19 @@ class MongoDB:
|
|||||||
|
|
||||||
scan_attrs = OrderedDict()
|
scan_attrs = OrderedDict()
|
||||||
scan_length = []
|
scan_length = []
|
||||||
|
|
||||||
for attrs_key in dropped_attrs.keys():
|
for attrs_key in dropped_attrs.keys():
|
||||||
flag = True
|
flag = True
|
||||||
for key in scan_attrs.keys():
|
for key in scan_attrs.keys():
|
||||||
if equivalent(scan_attrs[key], dropped_attrs[attrs_key]):
|
if equivalent(scan_attrs[key], dropped_attrs[attrs_key]):
|
||||||
flag = False
|
flag = False
|
||||||
|
|
||||||
result.update({attrs_key: key})
|
result.update({attrs_key: key})
|
||||||
|
|
||||||
break
|
break
|
||||||
if flag:
|
if flag:
|
||||||
scan_attrs.update({
|
scan_attrs.update({
|
||||||
attrs_key: dropped_attrs[attrs_key]
|
attrs_key: dropped_attrs[attrs_key]
|
||||||
})
|
})
|
||||||
scan_length = np.append(scan_length, len(dropped_attrs[attrs_key]))
|
scan_length = np.append(scan_length, len(dropped_attrs[attrs_key]))
|
||||||
|
|
||||||
result.update(
|
result.update(
|
||||||
{
|
{
|
||||||
@ -381,7 +395,7 @@ class MongoDB:
|
|||||||
if field is None:
|
if field is None:
|
||||||
field = globalDict
|
field = globalDict
|
||||||
|
|
||||||
res = field
|
res = {}
|
||||||
|
|
||||||
for key in field:
|
for key in field:
|
||||||
if isinstance(globalDict[key], dict) and ('mongoID' in globalDict[key]):
|
if isinstance(globalDict[key], dict) and ('mongoID' in globalDict[key]):
|
||||||
|
5140
testMongoDB.ipynb
5140
testMongoDB.ipynb
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user