maxhlc / assam

Open, lightweight tool for space telescope scheduling.
MIT License
3 stars 2 forks source link

GMAT_output.dat not found? #2

Closed HajimeKawahara closed 2 years ago

HajimeKawahara commented 2 years ago

@maxhlc @kawatadaisuke

@ykawashima and I are now trying to use assam. Thank you for sharing this code! Our question is, when performing main.py, we had the same error on GMAT_output.dat Can you show us some tutorial to start to use assam?

Best

Hajime Kawahara

beecomb ~/assam(main)>python main.py
/home/kawahara/anaconda3/lib/python3.7/site-packages/pandas/compat/_optional.py:138: UserWarning: Pandas requires version '2.7.0' or newer of 'numexpr' (version '2.6.8' currently installed).
  warnings.warn(msg, UserWarning)
GMAT Execution:   0%|                                                                             | 0/1 [00:00<?, ?it/s]sh: 1: GMAT: not found
GMAT Execution: 100%|█████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 82.34it/s]
Traceback (most recent call last):
  File "main.py", line 105, in <module>
    propagator, visibility, scheduling, visualisation = main()
  File "main.py", line 71, in main
    spacecraft_frame = propagator.propagate_spacecraft()
  File "/home/kawahara/assam/assam/propagator/propagator_module.py", line 94, in propagate_spacecraft
    gmat.load_state()
  File "/home/kawahara/assam/assam/propagator/gmat_interface.py", line 164, in load_state
    output = pd.read_fwf(OUTPUT_PATH)
  File "/home/kawahara/anaconda3/lib/python3.7/site-packages/pandas/io/parsers/readers.py", line 762, in read_fwf
    return _read(filepath_or_buffer, kwds)
  File "/home/kawahara/anaconda3/lib/python3.7/site-packages/pandas/io/parsers/readers.py", line 482, in _read
    parser = TextFileReader(filepath_or_buffer, **kwds)
  File "/home/kawahara/anaconda3/lib/python3.7/site-packages/pandas/io/parsers/readers.py", line 811, in __init__
    self._engine = self._make_engine(self.engine)
  File "/home/kawahara/anaconda3/lib/python3.7/site-packages/pandas/io/parsers/readers.py", line 1040, in _make_engine
    return mapping[engine](self.f, **self.options)  # type: ignore[call-arg]
  File "/home/kawahara/anaconda3/lib/python3.7/site-packages/pandas/io/parsers/python_parser.py", line 1203, in __init__
    PythonParser.__init__(self, f, **kwds)
  File "/home/kawahara/anaconda3/lib/python3.7/site-packages/pandas/io/parsers/python_parser.py", line 95, in __init__
    self._open_handles(f, kwds)
  File "/home/kawahara/anaconda3/lib/python3.7/site-packages/pandas/io/parsers/base_parser.py", line 229, in _open_handles
    errors=kwds.get("encoding_errors", "strict"),
  File "/home/kawahara/anaconda3/lib/python3.7/site-packages/pandas/io/common.py", line 706, in get_handle
    newline="",
FileNotFoundError: [Errno 2] No such file or directory: '/home/kawahara/assam/assam/propagator/GMAT/GMAT_output.dat'
maxhlc commented 2 years ago

Hi @HajimeKawahara,

Sorry to hear that you are having problems with the code. My first thought would be that GMAT is not executing correctly, and therefore is not producing the required output file.

Could you send over the contents of the /assam/propagator/GMAT/ directory? I will take a look to see if there is an issue with the generated files.

Kind regards,

Max

HajimeKawahara commented 2 years ago

@maxhlc Thank you for the quick reply! here is the contents.

beecomb ~/assam/assam/propagator/GMAT(main)>ls -lh
total 16K
-rw-rw-r-- 1 kawahara kawahara 6.6K Nov 25 12:31 GMAT_modified.script
-rw-rw-r-- 1 kawahara kawahara 6.5K Nov 25 12:14 GMAT_template.script
maxhlc commented 2 years ago

Ok, that definitely means that GMAT is not executing as there is no output. Could you send the GMAT_modified.script file?

HajimeKawahara commented 2 years ago

Here is GMAT_modified.script: https://gist.github.com/HajimeKawahara/ae5bdd7acdf208c00dd5eaab65142a49

maxhlc commented 2 years ago

Thank you.

It looks like it is formatted correctly. Does the script run (and produce the output file) if you execute it manually through the GMAT GUI?

HajimeKawahara commented 2 years ago

Ah, I see. This looks related to how to call GMAT. I use the Linux version of GMAT, in a remote environment (GUI unavailable), gmat-ubuntu-x64-R2020a.tar.gz, downloaded here. But, probably I should use the Windows version instead.

maxhlc commented 2 years ago

In theory it should be OS agnostic, however on the Python side I might have implemented it in a way that only works on Windows.

GMAT is called by GMATInterface.execute_script() in assam/propagator/gmat_interface.py. Lines 135-141 of that file define the command that is executed, under the assumption that GMAT is on the system path. It might be as simple as updating command = "GMAT" to instead use the full path to the GMAT executable.

HajimeKawahara commented 2 years ago

Thank you! @maxhlc In fact, it worked after some correction of the lines you specified!

@ykawashima, this procedure allows me to execute python main.py (in Ubuntu 20.04 environment)

linux version

download GMAT 2020a

Download gmat-ubuntu-x64-R2020a.tar.gz, from here. Ungzip it. Copy R2020a/lib/* to /usr/lib or just set LD_LIBRARY_PATH to this directory.

edit assam/propagator/gmat_interface.py

The executable on CUI is GMAT/R2020a/bin/GmatConsole. You don't need -m -x flags in this case. So, for instance,


        # Define command to run GMAT
        # command = "GMAT"
        command = "/home/kawahara/GMAT/R2020a/bin/GmatConsole"
        # Define flags when running GMAT
        # (-r: run script, -m: run minimised, -x: exit when finished)
        # flags = "-r -m -x"
        flags = "-r"

test run

cd assam
python main.py

This results in

beecomb ~/assam(features/linux)>python main.py
/home/kawahara/anaconda3/lib/python3.7/site-packages/pandas/compat/_optional.py:138: UserWarning: Pandas requires version '2.7.0' or newer of 'numexpr' (version '2.6.8' currently installed).
  warnings.warn(msg, UserWarning)
/home/kawahara/assam/assam/propagator/GMAT/GMAT_output.dat <==
GMAT Execution:   0%|                                                                             | 0/1 [00:00<?, ?it/s]
********************************************
***  GMAT Console Application
********************************************

General Mission Analysis Tool
Console Based Version
Build Date: Apr 30 2020  09:12:53

GMAT working directory set to '/home/kawahara/GMAT/R2020a/bin/'
Moderator is updating data files...
Moderator is creating core engine...

libmx.so: cannot open shared object file: No such file or directory
*** Library "../plugins/libMatlabInterface" did not open.
Skipping "../plugins/libOpenFramesInterface": GUI plugins are skipped in console mode
Successfully set Planetary Source to use: DE405
Successfully set Planetary Source to use: DE405
Successfully set Planetary Source to use: DE405
Setting nutation file to ../data/planetary_coeff/NUTATION.DAT
Setting leap seconds file to ../data/time/tai-utc.dat
2021-11-26 08:08:12 GMAT Moderator successfully created core engine

Interpreting scripts from the file.
***** file: /home/kawahara/assam/assam/propagator/GMAT/GMAT_modified.script
Successfully set Planetary Source to use: DE405
Successfully set Planetary Source to use: DE405
Successfully interpreted the script
.................... Print out the whole sequence ........................................
   Command::NoOp
   Command::BeginMissionSequence
   Command::Propagate
.................... End sequence ........................................................
Running mission...
Successfully set Planetary Source to use: DE405
Successfully set Planetary Source to use: DE405
Kernel ../data/planetary_ephem/spk/DE405AllPlanets.bsp has been loaded.
Kernel ../data/planetary_coeff/SPICEPlanetaryConstantsKernel.tpc has been loaded.
Kernel ../data/time/SPICELeapSecondKernel.tls has been loaded.
Kernel ../data/planetary_coeff/SPICEEarthPredictedKernel.bpc has been loaded.
Kernel ../data/planetary_coeff/SPICEEarthCurrentKernel.bpc has been loaded.
Kernel ../data/planetary_coeff/earth_latest_high_prec.bpc has been loaded.
Kernel ../data/planetary_coeff/SPICELunaCurrentKernel.bpc has been loaded.
Kernel ../data/planetary_coeff/SPICELunaFrameKernel.tf has been loaded.
Mission run completed.
===> Total Run Time: 57.917 seconds

========================================

*** GMAT Integration test (Console version) successful! ***

Moderator is deleting core engine...
GMAT Execution: 100%|█████████████████████████████████████████████████████████████████████| 1/1 [00:58<00:00, 58.20s/it]
Downloading https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/de430.bsp
|==================================================================================| 119M/119M (100.00%)         4s
Solar Body Generation: 100%|████████████████████████████████████████████████████████████| 10/10 [00:35<00:00,  3.56s/it]
Target Generation: 100%|██████████████████████████████████████████████████████████████| 350/350 [00:30<00:00, 11.60it/s]
Target Visibility: 100%|██████████████████████████████████████████████████████████████| 350/350 [01:48<00:00,  3.23it/s]
Target Contacts: 100%|████████████████████████████████████████████████████████████████| 350/350 [05:22<00:00,  1.09it/s]
Target Overall Statistics: 100%|█████████████████████████████████████████████████████| 350/350 [00:01<00:00, 208.73it/s]
Calculating Predecessors: 100%|████████████████████████████████████████████| 1359750/1359750 [00:27<00:00, 50221.56it/s]
Scheduling: 100%|██████████████████████████████████████████████████████████| 1359750/1359750 [00:33<00:00, 40662.66it/s]

The colormap="crest" does not work on my environment, so needed to modify, but anyway it worked! Thanks a lot @maxhlc.

ykawashima commented 2 years ago

Thank you very much @maxhlc and @HajimeKawahara !! It worked in my environment too.

maxhlc commented 2 years ago

I'm glad to hear that this resolved the issue!