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

Error in the code of Example_MMS_PDist.m #154

Open
Sibghat46 opened this issue Oct 24, 2024 · 3 comments
Open

Error in the code of Example_MMS_PDist.m #154

Sibghat46 opened this issue Oct 24, 2024 · 3 comments
Assignees

Comments

@Sibghat46
Copy link

hi,
My Matlab version is R2023a.
irfu-matlab version: v1.16.3
Operating system 64-bit operating system, x64-based processor
Windows 11 pro.

Many irfu-matlab codes run nicely on my system but I have never been able to run this code for particle distributions {Example_MMS_PDist.m}. It loads the file but the error occurs in the desDist.time function. Here I have pasted the errors that I am getting.

Particle_Distributions_MMS
[warning: mms_db.add_db(20)] Database [C:\Users\sibgh\pydata] already added

db_info =

struct with fields:

local_file_db_root: 'C:\Users\sibgh\pydata'

Time: 2020-02-19T00:39:00.000000000Z
Directory: C:\Users\sibgh\pydata\mms2\fpi\brst\l2\des-dist\2020\02\19
File: mms2_fpi_brst_l2_des-dist_20200219003833_v3.4.0.cdf (156532063 bytes)
[warning: make_pdist(86)] Times shifted to center of dt-+. dt-+ are recalculated
[warning: make_pdist(86)] Times shifted to center of dt-+. dt-+ are recalculated
Unable to resolve the name 'desDist2.time'.

Error in c_eval (line 48)
for cl_id=sc_list_1, evalin('caller', irf_ssub(ev_str, cl_id)), end

Error in Particle_Distributions_MMS (line 23)
c_eval('ePDist? = PDist(desDist?.time,desDist?.data,''skymap'',energy,ephi?.data,etheta?.data);',ic)

Particle_Distributions_MMS
[warning: mms_db.add_db(20)] Database [C:\Users\sibgh\pydata] already added

db_info =

struct with fields:

local_file_db_root: 'C:\Users\sibgh\pydata'

Time: 2015-10-30T05:15:45.000000000Z
Directory: C:\Users\sibgh\pydata\mms3\fpi\brst\l2\des-dist\2015\10\30
File: mms3_fpi_brst_l2_des-dist_20151030051444_v3.3.0.cdf (335671916 bytes)
[warning: make_pdist(86)] Times shifted to center of dt-+. dt-+ are recalculated
[warning: make_pdist(86)] Times shifted to center of dt-+. dt-+ are recalculated
Unable to resolve the name 'desDist3.time'.

Error in c_eval (line 48)
for cl_id=sc_list_1, evalin('caller', irf_ssub(ev_str, cl_id)), end

Error in Particle_Distributions_MMS (line 23)
c_eval('ePDist? = PDist(desDist?.time,desDist?.data,''skymap'',energy,ephi?.data,etheta?.data);',ic)

Particle_Distributions_MMS
[warning: mms_db.add_db(20)] Database [C:\Users\sibgh\pydata] already added

db_info =

struct with fields:

local_file_db_root: 'C:\Users\sibgh\pydata'

Time: 2015-10-30T05:15:45.000000000Z
Directory: C:\Users\sibgh\pydata\mms4\fpi\brst\l2\des-dist\2015\10\30
File: mms4_fpi_brst_l2_des-dist_20151030051444_v3.3.0.cdf (334346646 bytes)
[warning: make_pdist(86)] Times shifted to center of dt-+. dt-+ are recalculated
[warning: make_pdist(86)] Times shifted to center of dt-+. dt-+ are recalculated
Unable to resolve the name 'desDist4.time'.

Error in c_eval (line 48)
for cl_id=sc_list_1, evalin('caller', irf_ssub(ev_str, cl_id)), end

Error in Particle_Distributions_MMS (line 23)
c_eval('ePDist? = PDist(desDist?.time,desDist?.data,''skymap'',energy,ephi?.data,etheta?.data);',ic)

@thomas-nilsson-irfu
Copy link
Member

Dear @Sibghat46,
thanks for reaching out to us regarding irfu-matlab, I will refer this issue to @cecilianorgren who wrote much of the PDist.m code used by this example.

@cecilianorgren
Copy link
Member

Hi,

The line

c_eval('ePDist? = PDist(desDist?.time,desDist?.data,''skymap'',energy,ephi?.data,etheta?.data);',ic)

assumes you have a PDist distribution loaded with the name desDist3 (3 if ic = 3). If you run the code from the beginning, maybe this is not the case (because the first example loads the PDist in as ePDist3 and iPDist3). The error thus likely comes from the fact that you try to access a field of a non-existent variable. By adding

c_eval('desDist? = ePDist?',ic)

before you execute the part of the code that gives you the error, the error might go away.

However, this example is just to show that there are several ways to construct your PDist. I.e. this example uses an already existing PDist to make a copy of it. The same is the case for

c_eval('ePDist? = irf.ts_skymap(desDist?.time,desDist?.data,[],ephi?.data,etheta?.data,''energy0'',eenergy0?.data,''energy1'',eenergy1?.data,''esteptable'',estepTable?.data);',ic)

It is thus not meaningful to run the example from the start to the end.

The example is also slightly outdated, and I will try to update it in the near future. And then I will also provide better comments, and properly make the needed variables.

Let me know if this helps for now. Please also feel free to ask any other questions!

Best wishes,
Cecilia

@Sibghat46
Copy link
Author

My apologies for the late reply!
But even after these adjustments I am getting another error with "evalin".

Particle_Distributions_MMS
[warning: mms_db.add_db(20)] Database [C:\Users\sibgh\pydata] already added

db_info =

struct with fields:

local_file_db_root: 'C:\Users\sibgh\pydata'

Time: 2015-10-30T05:15:45.000000000Z
Directory: C:\Users\sibgh\pydata\mms4\fpi\brst\l2\des-dist\2015\10\30
File: mms4_fpi_brst_l2_des-dist_20151030051444_v3.3.0.cdf (334346646 bytes)
[warning: make_pdist(86)] Times shifted to center of dt-+. dt-+ are recalculated
[warning: make_pdist(86)] Times shifted to center of dt-+. dt-+ are recalculated

desDist4 =

PDist with properties:

            type: 'skymap'
         species: 'electrons'
          depend: {[5998×32 single]  [5998×32 single]  [5.6250 16.8750 28.1250 39.3750 50.6250 61.8750 73.1250 84.3750 … ]}
       ancillary: [1×1 struct]
            data: [5998×32×32×16 double]
            time: [5998×1 EpochTT]
coordinateSystem: ''
     tensorOrder: 0
     tensorBasis: ' ()'
  representation: {{1×1 cell}  {1×1 cell}  {1×1 cell}}
            name: 'mms4_des_dist_brst'
           units: 's^3/cm^6'
    siConversion: '1e12'
        userData: [1×1 struct]

Error using evalin
Unrecognized function or variable 'energy'.

Error in c_eval (line 48)
for cl_id=sc_list_1, evalin('caller', irf_ssub(ev_str, cl_id)), end

Error in Particle_Distributions_MMS (line 25)
c_eval('ePDist? = PDist(desDist?.time,desDist?.data,''skymap'',energy,ephi?.data,etheta?.data);',ic)

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

No branches or pull requests

3 participants