%%% read_hdf4_map_data
%
%%% Given a map hdf4 file, this function returns 
%%% the map data and scales (phi and sin-lat)
%%% both in double precision.
%
%%% Example uses for euv and chm maps:
%
%%% [map,p,sl] = read_hdf4_map_data('myEUVmapdata.hdf');
%%%              pcolor(p,sl,M);shading flat;caxis([0 3]);
%
%%% [map2,p2,sl2] = read_hdf4_map_data('myCHMmapdata.hdf');
%%%                 pcolor(p2,sl2,M2);shading flat;caxis([0 10]);

function [MAP,phi,sinlat] = read_hdf4_map_data(filename)

  % Get data:
  MAP = double(hdfread(filename,'/Data-Set-2'));

  % Get scales:
  hdf_info = hdfinfo(filename);
  phi      = double(hdf_info.SDS.Dims(2).Scale);
  sinlat   = double(hdf_info.SDS.Dims(1).Scale);
  
end
