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

Rotation of section vectors to normal #107

Open
HarryLuyt opened this issue Oct 11, 2021 · 2 comments
Open

Rotation of section vectors to normal #107

HarryLuyt opened this issue Oct 11, 2021 · 2 comments
Assignees

Comments

@HarryLuyt
Copy link
Contributor

In the m2section routine, used to extract a section (defined in the sections.in file) from the model and export the data to netCDF, possible arguments include rotation options. Two are listed:

  • -rotll to rotate vectors to lat/lon (or northward/eastward) components; and
  • -rotnormal to rotate vectors to the section normal and tangential components.

However, the -rotnormal option is not implemented yet, see snippet below:

! Rotate to east/north components for vectors
if (fld(j)%vecflag) then
if (velrot==1) then
uname='east_'//trim(fld(j)%fextract)
vname='north_'//trim(fld(j+1)%fextract)
call rotate(field,field2,plat,plon,idm,jdm,'m2l')
else if (velrot==2) then
print *,'Normal rotation not implemented yet'
stop
else if (velrot==0) then
uname=trim(fld(j)%fextract)
vname=trim(fld(j+1)%fextract)
else
print *,'Unknown rotation flag',velrot
stop
end if
end if

This means that users will currently need to rotate to normal using their code of choice in their analysis. This isn't a difficult task, but would be much easier if done in the m2section routine, especially if the bearing between the start and end points isn't known to the user.

A potential solution:
I am not yet confident in the mathematics of vectors and my knowledge thereof is limited, so my way of solving this might be rudimentary. In fact, this is how I would do it using the vector components if given in lat/lon rotation:

  1. I would first calculate the vector magnitude using Pythagoras from the east/north components.
  2. Then I would calculate direction relative to north (0 degrees) from the components using the arctan and some if-statements to determine its cartesian quadrant.
  3. Add the relative degrees for the quadrant that the vector is in.
  4. Then I would calculate the angle between my section start and end points (if I don't already know it).
  5. Add or subtract this angle to the vector directions.
  6. Decompose the vectors into components relative to the new direction.

There are probably much smoother ways to do this using vector mathematics which I am not familiar with.

@lbertino pointed out that this rotation must also be sensitive to the fact that connected subsections (also defined in the sections.in file) will likely consist of 'multiple normals', so to speak---each subsection could have a unique bearing between start and end points. So a unique rotation to normal is required for each subsection. This could require some work considering that the subsections are already joined using the sections_join subroutine when the section_intersect program is automatically called within m2section.

@HarryLuyt
Copy link
Contributor Author

I should add that a branch exists for these enhancements already:

https://github.com/nansencenter/NERSC-HYCOM-CICE/tree/adding_transport_instructions

@lbertino
Copy link
Collaborator

Thanks for throwing the ball, @HarryLuyt. On second thought, the section plot was intended for qualitative validation against moorings, which are often providing Northwards/Eastwards current measurements. But then I also agree that looking at normal currents across the section makes sense intuitively, but it does not need to care for conservation of mass like the transports routine does, so you can take the vector joining the beginning and the end of the section and rotate the vector as in this formula https://www.mathworks.com/help/phased/ref/rotz.html
Test it out for easy values of the angle (zero, 90 deg).
Then I could not help noticing the question about the section001.dat and transport001.dat files. These were the output files in the old times before we used NetCDF. The output was ASCII files intended for Tecplot. I think it should be OK to remove all that.

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

3 participants