Skip to content

Comments

Make FoV routine#449

Open
aburrell wants to merge 240 commits intodevelopfrom
make_fov
Open

Make FoV routine#449
aburrell wants to merge 240 commits intodevelopfrom
make_fov

Conversation

@aburrell
Copy link
Contributor

@aburrell aburrell commented Aug 6, 2021

A preliminary version of the routine that automatically determines the backscatter return direction. This partially addresses #135.

Test results using a fitacf 3.0 file:

make_fov -cn a ~/Programs/Data/SuperDARN/Downloads/19960916.0400.00.han.fitacf3 > han.tst_fov

This creates an ascii file with 13727 lines and the following columns:

#STID DATE TIME BMNUM BMAZM CPID INTT_SC INTT_US NAVE FRANG RSEP RXRISE FREQ NOISE ATTEN CHANNEL NRANG RG GFLG FOVFLG FOV_PAST GRPFLG GRPNUM GRPID P_0 P_0_ERR V V_ERR W_L W_L_ERR P_L P_L_ERR PHI0 PHI0_ERR ELV ELV_LOW ELV_HIGH VH VH_ERR VH_METHOD REGION HOP DIST MED_P_0 MED_P_0_ERR MED_V MED_V_ERR MED_W_L MED_W_L_ERR MED_P_L MED_P_L_ERR MED_PHI0 MED_PHI0_ERR OPP_ELV OPP_ELV_LOW OPP_ELV_HIGH OPP_VH OPP_VH_ERR OPP_VH_METHOD OPP_REGION OPP_HOP OPP_DIST

Re-creating one of the figures from my paper leads to similar results. This scan is from a different time that was created during various spot checks.

fov_fig4_test_third_scan

Before moving this from draft status we need to:

  • merge Find frequency bands #444
  • Move general utility functions into appropriate libraries
  • Create a fitacf-esq non-ascii output file option
  • Finalize command-line options

@aburrell
Copy link
Contributor Author

aburrell commented Aug 6, 2021

I am having issues compiling this on CentOS release 6.10.

Less worrying: I am getting this warning that may or may not need to be addressed:

$RSTPATH/include/base/rtypes.h:49: warning: ISO C90 does not support ‘long long’
$RSTPATH/include/base/rtypes.h:50: warning: ISO C90 does not support ‘long long’

The error (shortened for legibility):

$RSTPATH/lib/libfitacf.3.0.a(llist.o): In function `llist_sort':
llist.c:(.text+0x2d2): undefined reference to `pthread_rwlock_unlock'
llist.c:(.text+0x2e6): undefined reference to `pthread_rwlock_wrlock'
$RSTPATH/lib/libfitacf.3.0.a(llist.o): In function `llist_reverse':
llist.c:(.text+0x355): undefined reference to `pthread_rwlock_wrlock'
llist.c:(.text+0x365): undefined reference to `pthread_rwlock_unlock'
$RSTPATH/lib/libfitacf.3.0.a(llist.o): In function `llist_concat':
... et cetera ...
$RSTPATH/lib/libfitacf.3.0.a(llist.o): In function `llist_create':
llist.c:(.text+0xe26): undefined reference to `pthread_rwlockattr_setpshared'
llist.c:(.text+0xe36): undefined reference to `pthread_rwlock_init'
llist.c:(.text+0xe42): undefined reference to `pthread_rwlockattr_destroy'
collect2: ld returned 1 exit status
make: *** [make_fov] Error 1

I tried added the pthread.h and llist.h libraries to the routines that might possibly need them, but it didn't change anything.

@aburrell aburrell requested review from ecbland and egthomas August 6, 2021 20:09
@aburrell aburrell linked an issue Sep 23, 2021 that may be closed by this pull request
Copy link
Contributor Author

@aburrell aburrell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also need to remove "#rawrite.c#" file.

@aburrell
Copy link
Contributor Author

Ok @ecbland and @egthomas I am a bit stuck on the last step: creating a binary file. I can write a binary without issue, but I can't read it back in. This could be:

  • a problem writing a valid file, or
  • just a reading problem.

I added a utility fitmultbsidtoascii to help test this. Would appreciate help debugging, as I am stuck and lack dmap knowledge/experience.

@egthomas
Copy link
Member

@aburrell if it is a valid dmap-format file then you should be able to use

dmapdump [filename] > [output_filename]

to see all of the scalar fields in the file in plain-text format, or

dmapdump -d [filename] > [output_filename]

to see both the scalars and contents of any arrays.

@aburrell
Copy link
Contributor Author

Ok @egthomas the good news is that the output file is valid! The bad news is I still have things I need to fix 🙀 But that's a better problem to have.

@aburrell aburrell marked this pull request as ready for review November 23, 2021 15:25
@aburrell
Copy link
Contributor Author

@egthomas @ecbland this is now ready for review!

@aburrell aburrell requested a review from shibaji7 January 5, 2022 17:00
@ecbland ecbland added this to the RST 4.7 milestone Jan 28, 2022
@pasha-ponomarenko
Copy link
Contributor

@aburrell, I am a bit confused about how to test this routine.
I have installed the branch and ran make_fov on a FITACF file. The output seems to be in DMAP format rather than ASCII mentioned at the beginning of the issue. I can also see that it is a FITACF-like format but with extra fields.
Could you please provide a bit more comprehensive instructions for a non-initiated reviewer like me? :-)

@aburrell
Copy link
Contributor Author

aburrell commented Feb 3, 2022

@pasha-ponomarenko before I give you detailed instructions (which I am happy to do) could you try following the examples I wrote up in the local routine docs? I think it would be good to have someone unfamiliar with the routine, but a competent RST user try to follow them so I can use your feedback to make them clearer.

But to answer a quick question you raised, there are two output formats: ascii and a dmap binary. It is basically fitacf + some fields. Not all fields are used by this routine, some are there in preparation for the rest of the backscatter ID processing that I will code up following this pull.

@mts299
Copy link
Contributor

mts299 commented Feb 3, 2022

@aburrell sorry what are the new fields called?

Make sure to add them to pyDARNio so people can read them :)

@pasha-ponomarenko
Copy link
Contributor

@aburrell, do you mean this one?
https://github.com/SuperDARN/rst/blob/make_fov/codebase/superdarn/src.bin/tk/tool/make_fov.1.0/docs/make_fov.doc.xml

When I try to open it in a browser, I get this error:
image

It might be something very simple, but ...

@aburrell
Copy link
Contributor Author

aburrell commented Feb 3, 2022

I do mean that one! Unfortunately I do not know XML, so I made the docs by copy-pasta + add sauce. Can someone with XML knowledge take a look at that file and let me know what might be wrong? @pasha-ponomarenko do you know anyone with this skill set?

@mts299 the new fields are all in the new structure housed in $RSTPATH/codebase/superdarn/src.lib/tk/fitmultbsid.1.0/. All the parameters are explained in the docs in that file, so if you don't mind trying to read them and coming back with questions, I'd appreciate your partial review!

@mts299
Copy link
Contributor

mts299 commented Feb 3, 2022

I will do it next week (maybe), currently cannot stare at a screen due to a concussion. Was just looking for quick things to do or ask.

@pasha-ponomarenko
Copy link
Contributor

Apparently, there is a know issue with Github: one should never download a web file from Git as it will contain the Git webpage information as well:
process-intelligence-solutions/pm4py#247 (comment)

However, when I tried to open the same file from an RST package installed on my Linux desktop, it just showed a "raw" ASCII content and the following error(?) message:
"This XML file does not appear to have any style information associated with it. The document tree is shown below. "
This happens on both Linux and Windows.

@aburrell, are you able to see the document properly in your web browser?

@aburrell
Copy link
Contributor Author

aburrell commented Feb 3, 2022

are you able to see the document properly in your web browser

No, but I don't know how to open up any of the RST xml docs. So it's a matter of me not knowing how to create something that I could open. Do you just try to open the xml files in a web browser?

@pasha-ponomarenko
Copy link
Contributor

Yep, I believe that what you are supposed to do with XMLs.

@aburrell
Copy link
Contributor Author

aburrell commented Feb 3, 2022

So, opening any of the files in a web browser doesn't do anything but display the code. I guess the good news is that my xml behaves the same as the rest of the xml. None of them open.

Given that it seems none of us have the knowledge to resolve this issue, here's what you need to run the code:

Create ascii output: make_fov -ascii
Use your own tdiff: make_fov -update-tdiff -tdiff <value_in_microseconds>
Specify your own frequency band: make_fov -tfmin -tfmax
Specify channel a: make_fov -cn a

Because you need to look at the range and azimuthal variations, you need to separate frequency bands for the analysis. For best results, use the TDIFF suited to the choses radar channel and frequency!

To convert the dmap binary to ascii, use fitmultbsidtoascii

@pasha-ponomarenko
Copy link
Contributor

Yep, the XML business looks like a separate issue.
:-(
Thanks for the clarification. Do you have a description of the extra fields in a more robust format like DOC or PDF? Or simple ASCII?

@ecbland
Copy link
Contributor

ecbland commented Feb 3, 2022

To view the documentation in a web browser, I think you first need to run make.doc from the root directory of RST.

cd $RSTPATH
make.doc
cd doc/html
google-chrome index.html &   # or another web browser of your choice

You can then navigate through the html documentation in the web browser.
The documentation for the make_fov binary is here: $RSTPATH/doc/html/superdarn/src.bin/tk/tool/make_fov/index.html

aburrell and others added 17 commits May 16, 2025 15:50
Added development gotchas and a summary of the FitMultBSID structures to the  docs.
Added missing asterisk to the docstring.
Fixed bugs involved in loading data from multiple binary files including:
- reading in multiple filenames from the command-line input,
- reading in the binary header data, and
- cycling through the new scans.
Made changes needed to use the new channel-dependent tdiff.
Update the parameter description for the lobe dependent elevation calculation.
Added a propagation path warning for the users.
Added the IDL tarball created when computers without IDL compile RST to the list of ignored files.
Added pointer initialization.
Added an evaluation for all elevation angles having extreme values (at the upper edge of elevation angle measurements).
Added support for extreme fov evaluation.
Updated the order in which the two fields of view are evaluated (front first) and incorporated support for extreme elevation angle evaluation.
Added a new gflg to the updated data structure.  Preserves original groundscatter flag `gsct`.
Initialize a new groundscatter flag value with the original groundscatter flag value when loading scans.
Update beam evaluation to use new groundscatter flag instead of the original groundscatter flag.
Updated the groundscatter flag evaluation to alter the new flag value and maintain the old one for continuity with previous code and ease of comparison.
aburrell added 4 commits May 16, 2025 16:26
Some libraries that `make_fit` needs were removed during the process of resolving merge conflicts.
Fixed a typo in the structure reference.
Removed unused variables from the `make_fov` functions.
Updated the mpfit library version.
Copy link
Contributor Author

@aburrell aburrell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@egthomas the compilation is failing for two routines that I can't see any connection to:

  • rpos_v2_test.1.0
  • make_sim.1.0

In both cases I think it's because the rpos.1 library is not being made correctly. Any idea why? I tried a few things without success.


struct CellBSIDFlgs
{
int gflg;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New groundscatter flag.

Comment on lines +244 to +255
if((strcmp(aptr->name, "gsct") == 0) && (aptr->type == DATASHORT)
&& (aptr->dim == 1))
{
for(j = 0; j < aptr->rng[0]; j++)
bm->rng[slist[j]].gsct = aptr->data.sptr[j];
}
else if((strcmp(aptr->name, "gflg") == 0) && (aptr->type == DATASHORT)
&& (aptr->dim == 1))
{
for(j = 0; j < aptr->rng[0]; j++)
bm->rng_flgs[slist[j]].gflg = aptr->data.sptr[j];
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now with two groundscatter flags (original and new).

{
sprintf(scan_info, "#STID");
sprintf(bm_info, "DATE TIME INTT_US BMNUM BMAZM CPID NAVE FRANG RSEP RXRISE FREQ NOISE ATTEN CHANNEL NRANG");
sprintf(rng_info, "RG GFLG NEW_GFLG FOVFLG FOV_PAST GRPFLG GRPNUM GRPID P_0 P_0_ERR V V_ERR W_L W_L_ERR P_L P_L_ERR PHI0 PHI0_ERR ELV ELV_LOW ELV_HIGH VH VH_ERR VH_METHOD REGION HOP DIST MED_P_0 MED_P_0_ERR MED_V MED_V_ERR MED_W_L MED_W_L_ERR MED_P_L MED_P_L_ERR MED_PHI0 MED_PHI0_ERR OPP_ELV OPP_ELV_LOW OPP_ELV_HIGH OPP_VH OPP_VH_ERR OPP_VH_METHOD OPP_REGION OPP_HOP OPP_DIST");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New groundscatter output is provided alongside original.

Comment on lines +115 to +116
gsct = DataMapStoreArray(ptr, "gsct", DATASHORT, 1, &ngood, NULL);
gflg = DataMapStoreArray(ptr, "gflg", DATASHORT, 1, &ngood, NULL);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New groundscatter flag provided alongside original. Original keeps the name, new flag has new name.

bm_new->rng[irg].elv = bm_old.rng[irg].elv;

/* Initialize the range gate flags */
bm_new->rng_flgs[irg].gflg = bm_new->rng[irg].gsct;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New gflg is initialized here.

}

/* Update the groundscatter flag */
EvalGroundScatter(beam);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updates to new gflag happen here.

* - at least 3 groundscatter points are found in a 10 range gate box
**/

void EvalGroundScatter(struct FitBSIDBeam *beam)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated this function to leave the original gsct flag alone.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding FoV detection, improved groundscatter flag

7 participants