Skip to content

Commit

Permalink
Merge pull request #48 from gisce/new_changes_in_corbagen
Browse files Browse the repository at this point in the history
Pasar a coma flotante las magnitudes del fichero CORBAGEN
  • Loading branch information
davidmunoznovoa authored Dec 3, 2024
2 parents e1280d7 + a68ea5b commit 9256913
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 31 deletions.
2 changes: 1 addition & 1 deletion cchloader/adapters/corbagen.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CorbaGenBaseAdapter(Schema):
@pre_load
def fix_numbers(self, data):
for attr, field in self.fields.items():
if isinstance(field, fields.Integer):
if isinstance(field, (fields.Integer, fields.Float)):
if not data.get(attr):
data[attr] = None
return data
Expand Down
6 changes: 3 additions & 3 deletions cchloader/models/corbagen.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class CorbaGenSchema(Schema):
name = fields.String(position=0, required=True)
local_timestamp = fields.DateTime(position=1, format='%Y-%m-%d %H:%M', required=True)
season = fields.Integer(position=2, validate=OneOf([0, 1]), required=True)
generacio = fields.Integer(position=3, required=True)
autocons = fields.Integer(position=4, required=True)
excedent = fields.Integer(position=5, required=True)
generacio = fields.Float(position=3, required=True)
autocons = fields.Float(position=4, required=True)
excedent = fields.Float(position=5, required=True)

CorbaGenSchema()
48 changes: 24 additions & 24 deletions spec/curve_files/CORBAGEN_202403.0
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
ES1234000000000001JN0F001;2024-03-01 01:00;0;0;0;0;
ES1234000000000001JN0F001;2024-03-01 02:00;0;0;0;0;
ES1234000000000001JN0F001;2024-03-01 03:00;0;0;0;0;
ES1234000000000001JN0F001;2024-03-01 04:00;0;0;0;0;
ES1234000000000001JN0F001;2024-03-01 05:00;0;0;0;0;
ES1234000000000001JN0F001;2024-03-01 06:00;0;40;0;40;
ES1234000000000001JN0F001;2024-03-01 07:00;0;80;0;80;
ES1234000000000001JN0F001;2024-03-01 08:00;0;100;40;60;
ES1234000000000001JN0F001;2024-03-01 09:00;0;100;40;60;
ES1234000000000001JN0F001;2024-03-01 10:00;0;150;40;110;
ES1234000000000001JN0F001;2024-03-01 11:00;0;150;40;110;
ES1234000000000001JN0F001;2024-03-01 12:00;0;200;40;160;
ES1234000000000001JN0F001;2024-03-01 13:00;0;200;40;160;
ES1234000000000001JN0F001;2024-03-01 14:00;0;150;40;110;
ES1234000000000001JN0F001;2024-03-01 15:00;0;150;40;110;
ES1234000000000001JN0F001;2024-03-01 16:00;0;100;40;60;
ES1234000000000001JN0F001;2024-03-01 17:00;0;100;40;60;
ES1234000000000001JN0F001;2024-03-01 18:00;0;80;40;40;
ES1234000000000001JN0F001;2024-03-01 19:00;0;40;40;0;
ES1234000000000001JN0F001;2024-03-01 20:00;0;0;0;0;
ES1234000000000001JN0F001;2024-03-01 21:00;0;0;0;0;
ES1234000000000001JN0F001;2024-03-01 22:00;0;0;0;0;
ES1234000000000001JN0F001;2024-03-01 23:00;0;0;0;0;
ES1234000000000001JN0F001;2024-03-02 00:00;0;0;0;0;
ES1234000000000001JN0F001;2024-03-01 01:00;0;0.0;0.0;0.0;
ES1234000000000001JN0F001;2024-03-01 02:00;0;0.0;0.0;0.0;
ES1234000000000001JN0F001;2024-03-01 03:00;0;0.0;0.0;0.0;
ES1234000000000001JN0F001;2024-03-01 04:00;0;0.0;0.0;0.0;
ES1234000000000001JN0F001;2024-03-01 05:00;0;0.0;0.0;0.0;
ES1234000000000001JN0F001;2024-03-01 06:00;0;40.4;0;40.4;
ES1234000000000001JN0F001;2024-03-01 07:00;0;80.534;0;80.534;
ES1234000000000001JN0F001;2024-03-01 08:00;0;100.0;40.0;60.0;
ES1234000000000001JN0F001;2024-03-01 09:00;0;100.0;40.0;60.0;
ES1234000000000001JN0F001;2024-03-01 10:00;0;150.0;40.0;110.0;
ES1234000000000001JN0F001;2024-03-01 11:00;0;150.0;40.0;110.0;
ES1234000000000001JN0F001;2024-03-01 12:00;0;200.0;40.0;160.0;
ES1234000000000001JN0F001;2024-03-01 13:00;0;200.0;40.0;160.0;
ES1234000000000001JN0F001;2024-03-01 14:00;0;150.0;40.0;110.0;
ES1234000000000001JN0F001;2024-03-01 15:00;0;150.0;40.0;110.0;
ES1234000000000001JN0F001;2024-03-01 16:00;0;100.0;40.0;60.0;
ES1234000000000001JN0F001;2024-03-01 17:00;0;100.0;40.0;60.0;
ES1234000000000001JN0F001;2024-03-01 18:00;0;80.0;40.0;40.0;
ES1234000000000001JN0F001;2024-03-01 19:00;0;40.0;40.0;0.0;
ES1234000000000001JN0F001;2024-03-01 20:00;0;0.0;0.0;0.0;
ES1234000000000001JN0F001;2024-03-01 21:00;0;0.0;0.0;0.0;
ES1234000000000001JN0F001;2024-03-01 22:00;0;0.0;0.0;0.0;
ES1234000000000001JN0F001;2024-03-01 23:00;0;0.0;0.0;0.0;
ES1234000000000001JN0F001;2024-03-02 00:00;0;0.0;0.0;0.0;
10 changes: 7 additions & 3 deletions spec/test_parsers_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,15 @@
expect(get_parser(filename)).to(equal(CorbaGen))
with it('CORBAGEN parser fits file format'):
with CchFile('spec/curve_files/CORBAGEN_202403.0') as cch_file:
line_number = 0
for line in cch_file:
expected_corbagen = 'ES1234000000000001JN0F001;2024-03-01 01:00;0;0;0;0;\n'
expected_corbagen = 'ES1234000000000001JN0F001;2024-03-01 07:00;0;80.534;0;80.534;\n'
result_corbagen = line['orig']
assert result_corbagen == expected_corbagen
break
if line_number == 6:
assert result_corbagen == expected_corbagen
break
line_number += 1
assert line_number == 6

with it('test to get REGANECU parser'):
for filename in self.reganecu_filenames:
Expand Down

0 comments on commit 9256913

Please sign in to comment.