Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrupted MagStar GMAG CDFs from cdf_make_vars #154

Closed
jameswilburlewis opened this issue Apr 22, 2024 · 6 comments
Closed

Corrupted MagStar GMAG CDFs from cdf_make_vars #154

jameswilburlewis opened this issue Apr 22, 2024 · 6 comments

Comments

@jameswilburlewis
Copy link
Contributor

From Cindy:

The pipeline to produce CDFs from MagStar GMAG data is producing corrupt CDFs.

Below is a summary of the MagStar procedures:

DOWNLOAD:
Download code includes:
/disks/socware/thmsoc_dp_current/src/ksh/magstar_get_csv.bash
/disks/socware/thmsoc_dp_current/src/python/magstar/dasi_themis_downloader.py

Download Process:
The bash script (cronjob) calls python code dasi_themis_downloader.py
dasi_themis_downloader downloads the last 21 days of csv files and copies them to the magstar ‘work2do’ directory /disks/themisdata/workdir/magstar2do/.

CONVERT TO CDF:
Conversion code includes:
/disks/socware/thmsoc_dp_current/src/ksh/magstar_csv2all.ksh
/disks/socware/thmsoc_dp_current/idl/thmsoc/magstar_gmag/thm_magstar_l2gen.pro

Conversion Process:

The ksh script (cronjob) magstar_csv2all.ksh lists the csv files that are in the magstar workdir /disks/themisdata/workdir/magstar2do and loops though each file calling the IDL routine thm_magstar_l2gen.pro
thm_magstar_l2gen.pro reads the csv file, uses the mastercdf file to create an l2_structure and calls cdf_save_vars to create the CDF file.

NOTES:

The Download process works well. Files have been downloaded through March 2024. The cronjob is currently commented out since the CDF files are not correct.
There is a file ready to be processed in the /disks/themisdata/workdir/magstar2do directory. All you need to do is run the script magstar_csv2all.ksh and it will find the file and create a CDF.
If you want to play with more csv files there is a temp directory disks/themisdata/workdir/magstar2do/temp/ that contains many csv files that can be copied up a directory and run.
A CDF file is created. It cannot, however, be loaded by thm_load_gmag. It is supposedly a corrupt CDF and is deleted when you try and load. Similarly, it cannot be loaded by matlab.
It occurred to me that perhaps the thm_load_gmag routine cannot handle the new magstar CDF files. They are using TT2000 datetime which is different from the time/range/epoch used by the older gmag files. Or possibly the CDF version is not current. I'll look into that.

@jameswilburlewis
Copy link
Contributor Author

Cindy said today that the cdf_save_vars code may be producing readable CDFs on her Mac, so that's another hint that the issue might have more to do with the environment or IDL installation than with cdf_save_vars itself.

@jimm02
Copy link

jimm02 commented Apr 23, 2024

So the problem is with the mastercdfs for the files that aren't working. The bad masters have the Magnetic field variable as non-record varying, and this causes the data_dimen variable to be (n,3) rather than 3, causing the crash.

@jimm02
Copy link

jimm02 commented Apr 23, 2024

Fixed, what was hapopning is that the l2gen program expected the time variable as the first tag in the structure loaded from the mastercdf, and the B field as the second. For the 'bad' files this was not the case, the first variable was the Bfield, the seond variable was units, and the time variable was fourth or fifth. The code that tests for this (see, e.g. thm_maccs_gmag_l2gen) was commented out in the magstar l2gen file. I fixed this, and updated the production IDL code. It should work now.

@jimm02
Copy link

jimm02 commented Apr 23, 2024

I reprocessed all of the files for 2024-03-19, they can be loaded, but the times are screwy.

@jimm02
Copy link

jimm02 commented Apr 24, 2024

Ok, I fixed the times in the magstar files. The problem was that the time array was defined as CDF_REAL8, and needed to be CDF_TIME_TT2000. This could be fixed in the mastercdfs for dmo, dhe, dbo, doh, dat, dma, and dme, but easier to add a line in the l2gen program that sets the datatype. I re-reprocessed all of the files for 2024-03-19, and no more problems.

@clrussell90404
Copy link

clrussell90404 commented Apr 24, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants