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:
- I would first calculate the vector magnitude using Pythagoras from the east/north components.
- 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.
- Add the relative degrees for the quadrant that the vector is in.
- Then I would calculate the angle between my section start and end points (if I don't already know it).
- Add or subtract this angle to the vector directions.
- 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.
In the
m2sectionroutine, 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:-rotllto rotate vectors to lat/lon (or northward/eastward) components; and-rotnormalto rotate vectors to the section normal and tangential components.However, the
-rotnormaloption is not implemented yet, see snippet below:NERSC-HYCOM-CICE/hycom/MSCPROGS/src/Section/p_section_plot.F90
Lines 152 to 168 in d0f744e
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
m2sectionroutine, 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:
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_joinsubroutine when thesection_intersectprogram is automatically called withinm2section.