Hi Chan, You can do this with string functions, directly from the netcdf file, without writing the intermediate file that others suggested. The first difficulty is that the file doesn't define the coordinate axes with any direction x,y,z, or t, and so Ferret just assigns them to a direction in the order that the coordinates are listed for each variable. Note how the dimension N_PROF appears differently for these two variables: yes? use argo_2900623_prof.nc yes? show grid temp GRID GTN4 name axis # pts start end N_LEVELS X 48 r 1 48 N_PROF Y 56 r 1 56 normal Z normal T yes? show grid temp_qc GRID GTN2 name axis # pts start end N_PROF X 56 r 1 56 normal Y normal Z normal T In fact, it looks like temp_c consists of 56 strings, each of length 48. We want to put temp_qc onto a Y axis so that it can be applied to the data along the y axis of temp. yes? LET temp_qc_y = RESHAPE(temp_qc,temp[i=1]) Now to pick individual characters out of temp_qc_y, use the SUBSTRING function. For each i along the length of the string, yes? LET ix = i[gx=temp] yes? LIST SUBSTRING(temp_qc_y, ix, 1) VARIABLE : SUBSTRING(TEMP_QC_Y, IX, 1) FILENAME : argo_2900623_prof.nc SUBSET : 48 by 56 points (X-Y) ... listing every 2th point 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 1 / 1:"1""1""1""1""1""1""1""1""1""1""1""1""1""4""1""1""1""1""1""1""1""1""1""1" 2 / 2:"1""1""1""1""1""1""1""1""1""1""1""1""1""1""1""1""1""1""1""1""1""1""1""1" 3 / 3:"1""1""1""1""1""1""1""1""1""1""1""1""1""1""1""1""1""1""1""1""1""1""1""1" ... Then we can define a mask function so that the mask is 1 if temp_qc_y is 1, 2, or 5. Use STRCMP to compare the substrings with the string "1", "2", "5". yes? LET mask1 = IF STRCMP( SUBSTRING(temp_qc_y, ix, 1) , "1") EQ 0 THEN 1 ELSE 0 yes? LET mask2 = IF STRCMP( SUBSTRING(temp_qc_y, ix, 1) , "2") EQ 0 THEN 1 ELSE 0 yes? LET mask5 = IF STRCMP( SUBSTRING(temp_qc_y, ix, 1) , "5") EQ 0 THEN 1 ELSE 0 yes? LET mask_sum = mask1 + mask2 + mask5 yes? LET mask = if mask_sum GE 0 THEN 1 ! (else it will be missing) Now finally we can apply this mask to the variable temp: yes? LET masked_temp = temp * mask yes? SHADE masked_temp Chan Joo Jang wrote: Hi Ferret users, I would like to mask a variable (say, temp) of the Argo float data using a quality flag that is stored in a character variable "temp_qc". In other words, I want to assign temp to a missing value if temp_qc is not one of 1, 2, or 5. The problem is that I do not know how to handle the character variable (temp_qc) to mask the temp variable. I fetched the ARGO float data files from http://www.usgodae.org/cgi-bin/argo_select.pl . One of those nc files (2900622_profile.nc) is attached for your reference, and detailed info is given in PS. Any idea or comment would be appreciated. Thanks in advance. Chan Joo PS) Followings are some info of the Argo file that I am working on. yes? use/order=zt 2900622_prof.nc yes? list temp_qc VARIABLE : quality flag FILENAME : 2900622_prof.nc SUBSET : 11 points (Z) 1 / 1:"11111111111111111111111111111111111111111111111 " 2 / 2:"111111111111111111111111111111111111111111111111" 3 / 3:"111111111111111111111111111111111111111111111111" 4 / 4:"111111111111111111111111111111111111111111111111" 5 / 5:"111111111111111111111111111111111111111111 " 6 / 6:"1111111144111111111111111111111 " 7 / 7:"1111111111111111111111111411111111111111111111 " 8 / 8:"1111111111111111111111111111111 " 9 / 9:"111111111 " 10 / 10:"11111 " 11 / 11:"11 yes? sh da currently SET data sets: 1> ./2900622_prof.nc (default) name title I J K L DATA_TYPE ... ... ... ... FORMAT_VERSION ... ... ... ... HANDBOOK_VERSION ... ... ... ... REFERENCE_DATE_TIME ... ... ... ... PLATFORM_NUMBER Float unique identifier ... ... 1:11 ... PROJECT_NAME ... ... 1:11 ... PI_NAME ... ... 1:11 ... STATION_PARAMETERS List of available parameters fo ... ... 1:3 1:11 CYCLE_NUMBER Float cycle number ... ... 1:11 ... DIRECTION Direction of the station profil ... ... ... ... DATA_CENTRE Data centre in charge of float ... ... 1:11 ... DATE_CREATION ... ... ... ... DATE_UPDATE Date of update of this file ... ... ... ... DC_REFERENCE Station unique identifier in da ... ... 1:11 ... DATA_STATE_INDICATOR Degree of processing the data h ... ... 1:11 ... DATA_MODE Delayed mode or real time data ... ... ... ... INST_REFERENCE Instrument type ... ... 1:11 ... WMO_INST_TYPE Coded instrument type ... ... 1:11 ... JULD Julian day (UTC) of the station ... ... 1:11 ... JULD_QC Quality on Date and Time ... ... ... ... JULD_LOCATION Julian day (UTC) of the locatio ... ... 1:11 ... LATITUDE Latitude of the station, best e ... ... 1:11 ... LONGITUDE Longitude of the station, best ... ... 1:11 ... POSITION_QC Quality on position (latitude a ... ... ... ... POSITIONING_SYSTEM Positioning system ... ... 1:11 ... PROFILE_PRES_QC Global quality flag of PRES pro ... ... ... ... PROFILE_TEMP_QC Global quality flag of TEMP pro ... ... ... ... PROFILE_PSAL_QC Global quality flag of PSAL pro ... ... ... ... PRES SEA PRESSURE ... ... 1:48 1:11 PRES_QC quality flag ... ... 1:11 ... PRES_ADJUSTED SEA PRESSURE ... ... 1:48 1:11 PRES_ADJUSTED_QC quality flag ... ... 1:11 ... PRES_ADJUSTED_ERROR SEA PRESSURE ... ... 1:48 1:11 TEMP SEA TEMPERATURE IN SITU ITS-90 ... ... 1:48 1:11 TEMP_QC quality flag ... ... 1:11 ... TEMP_ADJUSTED SEA TEMPERATURE IN SITU ITS-90 ... ... 1:48 1:11 TEMP_ADJUSTED_QC quality flag ... ... 1:11 ... TEMP_ADJUSTED_ERROR SEA TEMPERATURE IN SITU ITS-90 ... ... 1:48 1:11 PSAL PRACTICAL SALINITY ... ... 1:48 1:11 PSAL_QC quality flag ... ... 1:11 ... PSAL_ADJUSTED PRACTICAL SALINITY ... ... 1:48 1:11 PSAL_ADJUSTED_QC quality flag ... ... 1:11 ... PSAL_ADJUSTED_ERROR PRACTICAL SALINITY ... ... 1:48 1:11 PARAMETER List of parameters with calibra 1:1 ... 1:11 1:3 SCIENTIFIC_CALIB_EQUATION Calibration equation for this p 1:1 ... 1:11 1:3 SCIENTIFIC_CALIB_COEFFICIENT Calibration coefficients for th 1:1 ... 1:11 1:3 SCIENTIFIC_CALIB_COMMENT Comment applying to this parame 1:1 ... 1:11 1:3 CALIBRATION_DATE 1:1 ... 1:11 1:3 HISTORY_INSTITUTION Institution which performed act ... ... 1:11 1:0 HISTORY_STEP Step in data processing ... ... 1:11 1:0 HISTORY_SOFTWARE Name of software which performe ... ... 1:11 1:0 HISTORY_SOFTWARE_RELEASE Version/release of software whi ... ... 1:11 1:0 HISTORY_REFERENCE Reference of database ... ... 1:11 1:0 HISTORY_DATE Date the history record was cre ... ... 1:11 1:0 HISTORY_ACTION Action performed on data ... ... 1:11 1:0 HISTORY_PARAMETER Station parameter action is per ... ... 1:11 1:0 HISTORY_START_PRES Start pressure action applied o ... ... 1:11 1:0 HISTORY_STOP_PRES Stop pressure action applied on ... ... 1:11 1:0 HISTORY_PREVIOUS_VALUE Parameter/Flag previous value b ... ... 1:11 1:0 HISTORY_QCTEST Documentation of tests performe ... ... 1:11 1:0 Chan Joo |