<div dir="ltr"><div>The following is fine<br></div><div>   <font face="Courier New">dd = dd*(-1.0)</font></div><div><font face="Courier New">However, the following is preferred<br></font></div><div><font face="Courier New"> <font face="Courier New">dd = -dd</font></font></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Feb 3, 2019 at 4:27 PM MeteoBB <<a href="mailto:info@meteo-bb.de">info@meteo-bb.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF">
    Hi Dennis,<br>
    <br>
    thx. Seems to be work fine except for cases where the lat or lon is
    in western or southern hemisphere.<br>
    I added some code for this and so this is my final function for
    conversion of DMS to DD:<br>
    (if this is incorrect, please tell me)<br>
    <br>
    <font face="Courier New">;========================================================================<br>
      function dms2dd(dms:string)<br>
;========================================================================<br>
      <br>
      local dms_str, degrees, MINUTES, minutes, dd, cminutes<br>
      <br>
      begin<br>
      <br>
         dms_str  = str_strip(dms)<br>
         degrees  = totype(str_get_field(dms_str, 1, "."), "float")<br>
         cminutes = tochar(str_get_field(dms_str, 2,"."))<br>
         minutes  = totype(tostring(cminutes(0:1)), "float")  ; 2 places
      only!<br>
      <br>
         if (any(minutes.ge.60)) then<br>
             print("dms2dd: illegal minutes value >= 60")<br>
             exit<br>
         end if<br>
      <br>
         dd = abs(degrees) + (abs(minutes)/60.0)<br>
         if (any(tofloat(degrees).le.0.0)) then    ; degrees in western
      or southern hemisphere<br>
           dd = dd*(-1.0)<br>
         end if<br>
      <br>
         return(dd)<br>
      <br>
      end<br>
;========================================================================</font><br>
    <br>
    <br>
    <div class="gmail-m_-3732735517765691473moz-cite-prefix">Am 24.01.2019 um 21:12 schrieb Dennis
      Shea:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">
        <div dir="ltr">
          <div><br>
          </div>
          <div>Well, of course, NCL [other languages also] would treat
            the following as 'real' numbers<br>
          </div>
          <div>===</div>
          <div><br>
          </div>
          <div>undef ("dm_to_deg")<br>
            function dm_to_deg(DM:numeric)<br>
            ;  DM: latitude or longitude: structure:
            mantissa.characteristic<br>
            ;      Example: 54.41:  degrees.minute: mantissa=51, 
            characteristic=41</div>
          <div>local delim, dm_str, mantissa, CHARACTERISTIC,
            characteristic, deg</div>
          <div><br>
          </div>
          <div>begin<br>
               delim  = "."<br>
               dm_str = tostring(DM)<br>
               mantissa       = totype(str_get_field(dm_str, 1, delim),
            typeof(DM))<br>
               CHARACTERISTIC = tochar(str_get_field(dm_str, 2, delim))<br>
               characteristic =
            totype(tostring(CHARACTERISTIC(0:1)),typeof(DM))  ; 2 places<br>
               if (any(characteristic.ge.60)) then<br>
                   print("dm_to_deg: illegal characteristic value >=
            60")<br>
                   exit<br>
               end if<br>
               deg = mantissa + (characteristic/60.0)<br>
               deg@long_name = "degree coordinates"<br>
               deg@NCL_tag    = "dm_to_deg"<br>
               deg@info       = "global locations in degrees: derived
            from dm"<br>
               return(deg)<br>
            end<br>
;========================================================================<br>
            ;                       MAIN: dms ==>
            degrees_minute_second<br>
;========================================================================<br>
            <br>
              lat_dm  = 54.41                 ; not 'real' number,
            rather  (54° 41') <br>
              lat_deg = dm_to_deg(lat_dm)<br>
              print(lat_deg)<br>
              print("")<br>
              print("===============")<br>
              print("")<br>
              lon_dm  = 13.26                  ; not 'real' number,
            rather    (13° 26')<br>
              lon_deg = dm_to_deg(lon_dm)<br>
            <br>
          </div>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail-m_-3732735517765691473gmail-m_-577346718784465828gmail_attr">On
          Thu, Jan 24, 2019 at 9:54 AM MeteoBB <<a href="mailto:info@meteo-bb.de" target="_blank">info@meteo-bb.de</a>> wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div bgcolor="#FFFFFF"> Hello,<br>
             <br>
            i have station data with lat/lon-coordinates in DMS (degree,
            minutes). <br>
            I suppose NCL/NCAR always want's decimal coordinates as
            input? That's why my plotted data points appears at a wrong
            position.<br>
             <br>
            Example (this is my data looks like):<br>
            lat = 54.41 (54° 41') <br>
            lon = 13.26 (13° 26')<br>
             <br>
            I think I have to transform the coordinates from DMS to
            decimal, to have:<br>
            lat = 54.68<br>
            lon = 13.43<br>
             <br>
            Then the location will be placed correctly on map.<br>
             <br>
            My question: <br>
            Just wondering - is there really no built-in
            procedure/function for the conversion from DMS to decimal
            coordinates? I found nothing about these stuff in the
            mailing lists or on the web. <br>
            Furthermore, I am irritated that the tick labels are DMS in
            my example program (see at the end), but he expects decimal
            coordinates.<br>
            If there is no built-in function, has anyone a funtion to
            convert DMS to decimal or a workaround?<br>
             <br>
            Thanks a lot.<br>
             <br>
            Regards,<br>
            Robert<br>
            <br>
             <br>
            <font face="Courier New">begin<br>
              <br>
                wks  = gsn_open_wks ("png","test")        <br>
                res                        = True               <br>
                res@gsnMaximize            = True<br>
                res@gsnFrame               = False            <br>
                res@mpGridAndLimbOn        = True               <br>
                res@pmTickMarkDisplayMode  = "Always"           <br>
                res@mpMinLatF              = 54<br>
                res@mpMaxLatF              = 55<br>
                res@mpMinLonF              = 13<br>
                res@mpMaxLonF              = 14<br>
              <br>
                res@mpGridSpacingF         = 0.25<br>
                res@mpGridLineThicknessF   = 2.0<br>
                res@mpGridLineColor        = "Gray30"<br>
                res@mpOutlineBoundarySets  = "AllBoundaries"<br>
                res@mpDataBaseVersion      = "MediumRes"<br>
                res@mpDataSetName          = "Earth..4"       <br>
                res@mpGridAndLimbOn        = True<br>
               <br>
                mkres                      = True<br>
                mkres@gsMarkerIndex        = 16     ; Filled circle<br>
                mkres@gsMarkerSizeF        = 0.008<br>
              <br>
                plot   = gsn_csm_map(wks,res)<br>
                gsn_polymarker(wks,plot,13.26,54.41,mkres)<br>
                frame(wks)<br>
              <br>
              end<br>
              <br>
            </font><br>
          </div>
          _______________________________________________<br>
          ncl-talk mailing list<br>
          <a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
          List instructions, subscriber options, unsubscribe:<br>
          <a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
        </blockquote>
      </div>
    </blockquote>
    <br>
  </div>

_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</blockquote></div>