bradsease / oem

Python tools for working with Orbit Ephemeris Messages (OEMs)
MIT License
17 stars 5 forks source link

Namespaced xml #69

Closed TommasoPino closed 2 years ago

TommasoPino commented 3 years ago

I prepared this modification in order to handle the reading of an OEM file in XML format that has a namespace in it. The modification will remove from the tag the namespace, it is transparent for XML files without namespace.

bradsease commented 3 years ago

Hi @TommasoPino, thanks for your contribution! I'm not too familiar with XML namespaces. Do you have an example of an XML OEM with that format?

TommasoPino commented 3 years ago

The following XML is a close example of what my client asked me to process. The xmlns field of OEM structure will be added to all fields by lxml where for example OBJECT_NAME will be {urn:ccsds:schema:ndmxml}OBJECT_NAME.

To avoid that I followed the solution found in this StackOverflow answer here

<?xml version="1.0" encoding="UTF-8"?>
<oem xmlns="urn:ccsds:schema:ndmxml" id="CCSDS_OEM_VERS" version="2.0">
    <header>
        <COMMENT>This is a comment</COMMENT>
        <CREATION_DATE>2021-09-28T08:28:09.279</CREATION_DATE>
        <ORIGINATOR>Generator</ORIGINATOR>
    </header>
    <body>
        <segment>
            <metadata>
                <OBJECT_NAME>Satellite</OBJECT_NAME>
                <OBJECT_ID>12345</OBJECT_ID>
                <CENTER_NAME>EARTH</CENTER_NAME>
                <REF_FRAME>EME2000</REF_FRAME>
                <TIME_SYSTEM>UTC</TIME_SYSTEM>
                <START_TIME>2016-12-31T00:00:00.000</START_TIME>
                <STOP_TIME>2017-01-07T23:59:59.000</STOP_TIME>
            </metadata>
            <data>
                <COMMENT>This is a comment</COMMENT>
                <stateVector>
                    <EPOCH>2016-12-31T00:00:00.000</EPOCH>
                    <X>1548.73660685606500000000</X>
                    <Y>6453.91396525065830000000</Y>
                    <Z>-2.20667257529390650000</Z>
                    <X_DOT>0.94202103371824331000</X_DOT>
                    <Y_DOT>-0.22525219323386808000</Y_DOT>
                    <Z_DOT>7.77861731494300630000</Z_DOT>
                </stateVector>
                <stateVector>
                    <EPOCH>2016-12-31T00:02:00.000</EPOCH>
                    <X>1647.49906289765250000000</X>
                    <Y>6467.07303631885220000000</Y>
                    <Z>904.50945583217378000000</Z>
                    <X_DOT>0.70153204546164949000</X_DOT>
                    <Y_DOT>-1.21997704279991210000</Y_DOT>
                    <Z_DOT>7.71053662286629200000</Z_DOT>
                </stateVector>
                <stateVector>
                    <EPOCH>2016-12-31T00:04:00.000</EPOCH>
                    <X>1716.59626399367310000000</X>
                    <Y>6461.98950104656070000000</Y>
                    <Z>1794.89313078469630000000</Z>
                    <X_DOT>0.44835037270326061000</X_DOT>
                    <Y_DOT>-2.19296583274764820000</Y_DOT>
                    <Z_DOT>7.60681540029509070000</Z_DOT>
                </stateVector>
            </data>
        </segment>
    </body>
</oem>
bradsease commented 2 years ago

Apologies for losing track of this -- I think I understand now. If you revert the changes to setup.py I can merge this in.

TommasoPino commented 2 years ago

Hello @bradsease. As asked, I reverted the setup.py file. Have a nice day.

TommasoPino commented 2 years ago

Just a question, I encountered a problem installing the package directly from the repository due to the setup.py line you asked me to revert. It is possible to generalize the setup.py to avoid this problem. A "setup.cfg" could be useful in that sense

bradsease commented 2 years ago

Sorry about that -- I'll work on making that more general. I was focused on getting it to work with my CI/CD and didn't think about local use.