Commit d2cbdc59 authored by Javier Vegas-Regidor's avatar Javier Vegas-Regidor
Browse files

Fixed bug in cmorization

parent 3d6ee65f
......@@ -14,6 +14,7 @@ from earthdiagnostics.frequency import Frequency, Frequencies
from earthdiagnostics.modelingrealm import ModelingRealms
from earthdiagnostics.utils import TempFile, Utils
from earthdiagnostics.variable import VariableManager
from earthdiagnostics.datafile import NetCDFFile
class Cmorizer(object):
......@@ -421,9 +422,26 @@ class Cmorizer(object):
raise CMORException('Variable {0}:{1} can not be cmorized. Original filename does not match a recognized '
'pattern'.format(var_cmor.domain, var_cmor.short_name))
self.data_manager.send_file(temp, var_cmor.domain, var_cmor.short_name, self.startdate, self.member,
frequency=frequency, rename_var=variable, date_str=date_str, region=region,
move_old=True, grid=alias.grid, cmorized=True)
netcdf_file = NetCDFFile()
netcdf_file.data_manager = self.data_manager
netcdf_file.local_file = temp
netcdf_file.remote_file = self.data_manager.get_file_path(self.startdate, self.member,
var_cmor.domain, var_cmor.short_name, var_cmor,
None, frequency,
grid=alias.grid, year=None, date_str=date_str)
netcdf_file.data_convention = self.config.data_convention
netcdf_file.region = region
netcdf_file.frequency = frequency
netcdf_file.domain = var_cmor.domain
netcdf_file.var = var_cmor.short_name
netcdf_file.final_name = var_cmor.short_name
netcdf_file.prepare_to_upload(rename_var=variable)
netcdf_file.add_cmorization_history()
netcdf_file.upload()
if region:
region_str = ' (Region {})'.format(region)
else:
......
......@@ -445,7 +445,7 @@ class NetCDFFile(DataFile):
def create_link(self):
try:
self.data_manager.create_link(self.domain, self.remote_file, self.frequency, self.final_name,
self.grid, False, self.var_type)
self.grid, True, self.var_type)
except Exception as ex:
Log.error('Can not create link to {1}: {0}'.format(ex, self.remote_file))
......
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