On May 12, 1:06=A0pm, Spon <christoph.b...@[EMAIL PROTECTED]
> wrote:
> On May 12, 4:35 pm, kishore1...@[EMAIL PROTECTED]
wrote:
>
>
>
> > Hi,
> > Thanks for your suggestions, I modified according your suggestions.
> > Pl. go through my program
> > pro vfm_feature_flags1,val
>
> FUNCTION VFM_FEATURE_FLAGS1, Input
>
>
>
> > ; =A0this routine demonstrates how to read and extract values from a
> > feature
> > ; =A0classification flag 16-bit integer value in CALIPSO Level 2
> > Vertical
> > ; =A0Feature Mask files
> > ;
> > ; =A0INPUT:
> > ; =A0val - the feature classification flag value to be decoded
> > ;
> > ; =A0OUTPUT:
> > ; =A0all information is printed into the IDL log window
>
> =A0; Make sure input is usable
> IF Input GT 65535L OR Input LT -32767L THEN $
> =A0 MESSAGE, 'Input not a 16-bit flag.'
>
> =A0; Convert input to 16-bit value
> Val =3D UINT(Input)
>
>
>
> > print, val
>
> > feature_type =3D 0
> > feature_type_qa =3D 0
> > ice_water_phase =3D 0
> > ice_water_phase_qa =3D 0
> > feature_subtype =3D 0
> > cloud_aerosol_psc_type_qa =3D 0
> > horizontal_averaging =3D 0
>
> > Output =3D { feature_type:"", =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 $
> > =A0 =A0 =A0 =A0 =A0 =A0feature_type_qa:"", =A0 =A0 =A0 =A0 =A0 =A0 =A0
=
=A0$
> > =A0 =A0 =A0 =A0 =A0 =A0ice_water_phase:"", =A0 =A0 =A0 =A0 =A0 =A0 =A0
=
=A0$
> > =A0 =A0 =A0 =A0 =A0 =A0ice_water_phase_qa:"", =A0 =A0 =A0 =A0 =A0 =A0
$
> > =A0 =A0 =A0 =A0 =A0 =A0feature_subtype:"", =A0 =A0 =A0 =A0 =A0 =A0 =A0
=
=A0 =A0 =A0 =A0 =A0$
> > =A0 =A0 =A0 =A0 =A0 =A0cloud_aerosol_psc_type_qa:"", =A0 =A0 =A0$
> > =A0 =A0 =A0 =A0 =A0 =A0horizontal_averaging:""}
>
> > for i=3D0,15 do begin
> > =A0 if ((val and 2L^i) NE 0) then begin
> > =A0 =A0 print,'Bit set: ',i+1
> > =A0 =A0 case i+1 of
> > =A0 =A0 1 : feature_type =3D feature_type + 1
> > =A0 =A0 2 : feature_type =3D feature_type + 2
> > =A0 =A0 3 : feature_type =3D feature_type + 4
> > =A0 =A0 4 : feature_type_qa =3D feature_type_qa + 1
> > =A0 =A0 5 : feature_type_qa =3D feature_type_qa + 2
> > =A0 =A0 6 : ice_water_phase =3D ice_water_phase + 1
> > =A0 =A0 7 : ice_water_phase =3D ice_water_phase + 2
> > =A0 =A0 8 : ice_water_phase_qa =3D ice_water_phase_qa + 1
> > =A0 =A0 9 : ice_water_phase_qa =3D ice_water_phase_qa + 2
> > =A0 =A0 10 : feature_subtype =3D feature_subtype + 1
> > =A0 =A0 11 : feature_subtype =3D feature_subtype + 2
> > =A0 =A0 12 : feature_subtype =3D feature_subtype + 4
> > =A0 =A0 13 : cloud_aerosol_psc_type_qa =3D cloud_aerosol_psc_type_qa +
1=
> > =A0 =A0 14 : horizontal_averaging =3D horizontal_averaging + 1
> > =A0 =A0 15 : horizontal_averaging =3D horizontal_averaging + 2
> > =A0 =A0 16: horizontal_averaging =3D horizontal_averaging + 4
> > =A0 =A0 else:
> > =A0 =A0 endcase
> > =A0 endif
> > endfor
>
> > case feature_type of
> > 0 : Output.Feature_Type =3D 'invalid (bad or missing data)'
> > 1 : Output.Feature_Type =3D 'clear air"
> > 2 : begin
> > =A0 =A0 =A0 Output.Feature_Type =3D 'cloud'
> > =A0 =A0 =A0 case feature_subtype of
> > =A0 =A0 =A0 0 : Output.Feature_Subtype =3D 'low overcast, transparent'
> > =A0 =A0 =A0 1 : Output.Feature_Subtype =3D 'low overcast, opaque'
> > =A0 =A0 =A0 2 : Output.Feature_Subtype =3D 'transition strato***ulus'
> > =A0 =A0 =A0 3 : Output.Feature_Subtype =3D 'low, broken ***ulus'
> > =A0 =A0 =A0 4 : Output.Feature_Subtype =3D 'alto***ulus (transparent)'
> > =A0 =A0 =A0 5 : Output.Feature_Subtype =3D 'altostratus (opaque)'
> > =A0 =A0 =A0 6 : Output.Feature_Subtype =3D 'cirrus (transparent)'
> > =A0 =A0 =A0 7 : Output.Feature_Subtype =3D 'deep convective (opaque)'
> > =A0 =A0 =A0 else : Output,'*** error getting Feature Subtype'
>
> ELSE : Output.Feature_Subtype =3D '*** error getting Feature Subtype'
>
> > =A0 =A0 =A0 endcase
> > =A0 =A0 end
> > 3 : begin
> > =A0 =A0 =A0 Output.Feature_Type =3D 'aerosol'
> > =A0 =A0 =A0 case feature_subtype of
> > =A0 =A0 =A0 0 : Output.Feature_Subtype =3D 'not determined'
> > =A0 =A0 =A0 1 : Output.Feature_Subtype =3D 'clean marine'
> > =A0 =A0 =A0 2 : Output.Feature_Subtype =3D 'dust'
> > =A0 =A0 =A0 3 : Output.Feature_Subtype =3D 'polluted continental'
> > =A0 =A0 =A0 4 : Output.Feature_Subtype =3D 'clean continental'
> > =A0 =A0 =A0 5 : Output.Feature_Subtype =3D 'polluted dust'
> > =A0 =A0 =A0 6 : Output.Feature_Subtype =3D 'smoke'
> > =A0 =A0 =A0 7 : Output.Feature_Subtype =3D 'other"
> > =A0 =A0 =A0 else : Output,'*** error getting Feature Subtype'
>
> ELSE : Output.Feature_Subtype =3D '*** error getting Feature Subtype'
>
> > =A0 =A0 =A0 endcase
> > =A0 =A0 end
> > 4 : begin
> > =A0 =A0 =A0 Output.Feature_Type =3D 'stratospheric feature--PSC or
> > stratospheric aerosol'
> > =A0 =A0 =A0 case feature_subtype of
> > =A0 =A0 =A0 0 : Output.Feature_Subtype =3D 'not determined'
> > =A0 =A0 =A0 1 : Output.Feature_Subtype =3D 'non-depolarizing PSC'
> > =A0 =A0 =A0 2 : Output.Feature_Subtype =3D 'depolarizing PSC'
> > =A0 =A0 =A0 3 : Output.Feature_Subtype =3D 'non-depolarizing aerosol'
> > =A0 =A0 =A0 4 : Output.Feature_Subtype =3D 'depolarizing aerosol'
> > =A0 =A0 =A0 5 : Output.Feature_Subtype =3D 'spare'
> > =A0 =A0 =A0 6 : Output.Feature_Subtype =3D 'spare'
> > =A0 =A0 =A0 7 : Output.Feature_Subtype =3D 'other'
> > =A0 =A0 =A0 else : Output,'*** error getting Feature Subtype'
>
> ELSE : Output.Feature_Subtype =3D '*** error getting Feature Subtype'
>
> > =A0 =A0 =A0 endcase
> > =A0 =A0 end
> > 5 : Output.Feature_Type =3D 'surface'
> > 6 : Output.Feature_Type =3D 'subsurface'
> > 7 : Output.Feature_Type =3D 'no signal (totally attenuated)'
> > else : Output,'*** error getting Feature Type'
>
> ELSE : Output.Feature_Type =3D '*** error getting Feature Type'
>
> > endcase
>
> > case feature_type_qa of
> > 0 : Output.Feature_Type_QA =3D 'none'
> > 1 : Output.Feature_Type_QA =3D 'low'
> > 2 : Output.Feature_Type_QA =3D 'medium'
> > 3 : Output.Feature_Type_QA =3D 'high'
> > else : Output,'*** error getting Feature Type QA'
>
> ELSE : Output.Feature_Type_QA =3D '*** error getting Feature Type QA'
>
> > endcase
>
> > case ice_water_phase of
> > 0 : Output.Ice_Water_Phase =3D 'unknown/not determined'
> > 1 : Output.Ice_Water_Phase =3D 'ice'
> > 2 : Output.Ice_Water_Phase =3D 'water'
> > 3 : Output.Ice_Water_Phase =3D 'mixed phase'
> > else : Output,'*** error getting Ice/Water Phase'
>
> ELSE : Output.Ice_Water_Phase =3D '*** error getting Ice/Water Phase'
>
> > endcase
>
> > case ice_water_phase_qa of
> > 0 : Output.Ice_Water_Phase_QA =3D 'none'
> > 1 : Output.Ice_Water_Phase_QA =3D 'low'
> > 2 : Output.Ice_Water_Phase_QA =3D 'medium'
> > 3 : Output.Ice_Water_Phase_QA =3D 'high'
> > else : Output,'*** error getting Ice/Water Phase QA'
>
> ELSE : Output.Ice_Water_Phase_QA =3D '*** error getting Ice/Water Phase
> QA'
>
>
>
> > endcase
>
> > if (cloud_aerosol_psc_type_qa eq 0) then begin
> > =A0 Output.Cloud_Aerosol_PSC_Type_QA =3D 'not confident'
> > endif else begin
> > =A0 Output.Cloud_Aerosol_PSC_Type_QA =3D 'confident'
> > endelse
>
> > case horizontal_averaging of
> > 0 : Output.Horizontal_averaging =3D 'not applicable'
> > 1 : Output.Horizontal_averaging =3D '1/3 km'
> > 2 : Output.Horizontal_averaging =3D '1 km'
> > 3 : Output.Horizontal_averaging =3D '5 km'
> > 4 : Output.Horizontal_averaging =3D '20 km'
> > 5 : Output.Horizontal_averaging =3D '80 km'
> > else : Output,'*** error getting Horizontal averaging'
>
> ELSE : Output.Ice_Water_Phase =3D '*** error getting Ice/Water Phase'
>
>
>
>
>
> > endcase
> > help,Output,/structure
> > ;Return, Output
> RETURN, Output
> > end
> > Using above routine I wrote a small progam
> > data1=3D[44474, 36282, 28602, 28090]
>
> > for i=3D0,3 do begin
> > =A0 =A0 ;vfm_feature_flags,data1(i)
> > =A0 =A0 vfm_feature_flags1,data1(i)
> > =A0 =A0 pause=3D'' & read,pause
>
> > endfor
> > end
>
> > Only, problem is how to recall output parameters.
>
> Replace this very first line:
> pro vfm_feature_flags,val
>
> with
>
> function vfm_feature_flags,val
>
> then, down at the very end of the programme, remove the comment-out
> from this line
> =A0;Return, Output
>
> IDL has two types of programmes, 'procedures' and 'functions'.
> Functions will return an output. Procedures can only alter input
> parameters (although this can be used to effectively give output too).
> Functions are called slightly differently to procedures, though the
> code language in them is identical apart from the 'Return, A_Value'
> thing.
>
> To call the function, use:
> result =3D vfm_feature_flags(value)
>
> e.g.
> myoutput =3D vfm_feature_flags(36282u)
>
> Then you can look at the content of the output like this:
> help, myoutput, /structure
>
> or something like this:
> print, myoutput.feature_type
> to get a single output field from the structure.
>
> Regards,
> Chris
Hi Chris,
Now, its working fine, thanks a lot for your kind help.
This forum is very good for new IDL guys.
Regards,
Kishore


|