Skip to content

Rotation of section vectors to normal #107

Description

@HarryLuyt

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.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions