Giter VIP home page Giter VIP logo

Comments (4)

JrtPec avatar JrtPec commented on July 17, 2024

Great news! I'll put it on my to do list.

from entsoe-py.

JrtPec avatar JrtPec commented on July 17, 2024

So, I downloaded the code lists, and also the general CIM package.

I tried using the xmlschema library.

I was able to validate a downloaded generation xml-file using the corresponding xsd-file, like so:

import xmlschema

schema = xmlschema.XMLSchema('entsoe/codelists/CIM_2020-10-19/iec62325-451-6-generationload_v3_0.xsd')

schema.is_valid('generation_doc.xml')  # True
schema.to_dict('generation_doc.xml')

{'@xmlns': 'urn:iec62325.351:tc57wg16:451-6:generationloaddocument:3:0',
 'mRID': '974d8ef382cf479a96768c4c728736ca',
 'revisionNumber': '1',
 'type': 'A71',
 'process.processType': 'A01',
 'sender_MarketParticipant.mRID': {'@codingScheme': 'A01',
  '$': '10X1001A1001A450'},
 'sender_MarketParticipant.marketRole.type': 'A32',
 'receiver_MarketParticipant.mRID': {'@codingScheme': 'A01',
  '$': '10X1001A1001A450'},
 'receiver_MarketParticipant.marketRole.type': 'A33',
 'createdDateTime': '2020-10-21T10:36:59Z',
 'time_Period.timeInterval': {'start': '2017-09-27T22:00Z',
  'end': '2017-09-28T22:00Z'},
 'TimeSeries': [{'mRID': '1',
   'businessType': 'A01',
   'objectAggregation': 'A01',
   'inBiddingZone_Domain.mRID': {'@codingScheme': 'A01',
    '$': '10YAT-APG------L'},
   'quantity_Measure_Unit.name': 'MAW',
   'curveType': 'A01',
   'Period': [{'timeInterval': {'start': '2017-09-27T22:00Z',
      'end': '2017-09-28T22:00Z'},
     'resolution': 'PT60M',
     'Point': [{'position': 1, 'quantity': Decimal('5107')},
      {'position': 2, 'quantity': Decimal('5052')},
      {'position': 3, 'quantity': Decimal('5079')},
      {'position': 4, 'quantity': Decimal('4948')},
      {'position': 5, 'quantity': Decimal('4946')},
      {'position': 6, 'quantity': Decimal('5106')},
      {'position': 7, 'quantity': Decimal('5644')},
      {'position': 8, 'quantity': Decimal('7208')},
      {'position': 9, 'quantity': Decimal('7430')},
      {'position': 10, 'quantity': Decimal('7398')},
      {'position': 11, 'quantity': Decimal('7002')},
      {'position': 12, 'quantity': Decimal('6402')},
      {'position': 13, 'quantity': Decimal('5810')},
      {'position': 14, 'quantity': Decimal('5802')},
      {'position': 15, 'quantity': Decimal('5764')},
      {'position': 16, 'quantity': Decimal('5709')},
      {'position': 17, 'quantity': Decimal('6080')},
      {'position': 18, 'quantity': Decimal('7241')},
      {'position': 19, 'quantity': Decimal('7966')},
      {'position': 20, 'quantity': Decimal('8122')},
      {'position': 21, 'quantity': Decimal('7724')},
      {'position': 22, 'quantity': Decimal('5541')},
      {'position': 23, 'quantity': Decimal('5408')},
      {'position': 24, 'quantity': Decimal('5145')}]}]},
  {'mRID': '2',
   'businessType': 'A01',
   'objectAggregation': 'A01',
   'outBiddingZone_Domain.mRID': {'@codingScheme': 'A01',
    '$': '10YAT-APG------L'},
   'quantity_Measure_Unit.name': 'MAW',
   'curveType': 'A01',
   'Period': [{'timeInterval': {'start': '2017-09-27T22:00Z',
      'end': '2017-09-28T22:00Z'},
     'resolution': 'PT60M',
     'Point': [{'position': 1, 'quantity': Decimal('0')},
      {'position': 2, 'quantity': Decimal('0')},
      {'position': 3, 'quantity': Decimal('0')},
      {'position': 4, 'quantity': Decimal('0')},
      {'position': 5, 'quantity': Decimal('0')},
      {'position': 6, 'quantity': Decimal('0')},
      {'position': 7, 'quantity': Decimal('0')},
      {'position': 8, 'quantity': Decimal('0')},
      {'position': 9, 'quantity': Decimal('0')},
      {'position': 10, 'quantity': Decimal('0')},
      {'position': 11, 'quantity': Decimal('0')},
      {'position': 12, 'quantity': Decimal('0')},
      {'position': 13, 'quantity': Decimal('0')},
      {'position': 14, 'quantity': Decimal('0')},
      {'position': 15, 'quantity': Decimal('0')},
      {'position': 16, 'quantity': Decimal('0')},
      {'position': 17, 'quantity': Decimal('0')},
      {'position': 18, 'quantity': Decimal('0')},
      {'position': 19, 'quantity': Decimal('0')},
      {'position': 20, 'quantity': Decimal('0')},
      {'position': 21, 'quantity': Decimal('0')},
      {'position': 22, 'quantity': Decimal('0')},
      {'position': 23, 'quantity': Decimal('0')},
      {'position': 24, 'quantity': Decimal('0')}]}]}]}

So that's already a nice result, that could save us some effort when parsing files.

However, what I'd like is a way to convert the values such as 'businessType': 'A01' into its corresponding string value. I found these things in etso-code-lists.xsd.

However, I lack the experience with XML files to glue all this together... Any XML experts, or people with enough time on their hands to figure this out?

from entsoe-py.

JrtPec avatar JrtPec commented on July 17, 2024

The alternative approach would be to write a simple parser that grabs all those mappings from the code-lists file; and makes them accessible to the code similar to how it's done right now.
That would also reduce the maintenance effort whenever mappings change, we'd just have to switch out the file.

from entsoe-py.

ba1dr avatar ba1dr commented on July 17, 2024

That's tricky. I did not find a simlple solution (apart from writing a parser manully), but some dirty solution would be:

  • use gererateDS to create a source file with enums:

generateDS -o codelists_dummy_file.py urn-entsoe-eu-wgedi-codelists.xsd

class StandardAssetTypeList(Enum):
    """ET0031
    The identification of the type of asset."""
    A_01='A01' # Tieline A high voltage line used for cross border energy interconnections.
    A_02='A02' # Line A specific electric line within a country.
    A_03='A03' # Resource Object A resource that can either produce or consume energy.
    A_04='A04' # Generation A resource that can produce energy.
    A_05='A05' # Load A resource that can consume energy.
...
  • then use regex to convert comments to descriptions

Actually I prefer to use that generated py file as parser for xml files:

from ds_b15x import parseString as ds_parseString

doc = ds_parseString(xml_content, silence=True)
print(doc.createdDateTime)

from entsoe-py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.