# Re: [ferret_users] Changing SST regionally and combining the regions

 My suggestion below does not work as written; please disregard.  One could redefine the variables to use the idea: yes? let jj = j[g=sst] yes? let south = if jj ge 1 and jj le 15 then 1 else 0 yes? let mid = if jj ge 16 and jj le 41 then 1 else 0 yes? let north = if jj ge 42 and jj le 56 then 1 else 0 yes? let sstsouith = max(sst-2, -1.65) * south yes? let sstmid = max(sst-0.7, -1.65) * mid yes? let sstnorth = max(sst-1.6, -1.65) * north yes? let sst_masked = sstsouth + sstmid + sstnorth On 3/3/2015 8:35 AM, Ansley Manke wrote: I have another variation on the suggestions here.  Define: let sstSOUTH=max(sst[J=1:15]-2, -1.65) else 0 let sstMID=max(sst[J=16:41]-0.7, -1.65) else 0 let sstNORTH=max(sst[J=42:56]-1.6, -1.65) else 0   And then add the three to get a combined SST.  This method works nicely when there are a larger number of conditions you want to apply - I had a similar case with about 10 regions and this was simpler . Ansley On 3/2/2015 10:49 PM, Pearse Buchanan wrote: It worked! ^_^   You’ve made my day   From: Jian (Tony) Ma [mailto:tonyj.ma@xxxxxxxxx] Sent: Tuesday, 3 March 2015 5:36 PM To: Pearse Buchanan Cc: ferret_users@xxxxxxxx Subject: Re: [ferret_users] Changing SST regionally and combining the regions   replace your old variables by using this:   Let ssta1 = If y lt -40 then max(sst -2, -1.65) else sst ...   Or you can make the max on time at last. Sent from my iPhone On Mar 3, 2015, at 1:28 AM, Pearse Buchanan wrote: Thanks for the speedy reply Tony.   So I tried what you said and it makes a lot of sense. But I because the regions are uneven I get this message when attempting to save:   yes? save/file=ZC_sstemp5d.nc ssta **ERROR: inconsistent sizes of data regions: Y axis           SSTM has 26 points (J=16:41)           _expression_ has 56 points (J=01:56) yes? stat ssta **ERROR: inconsistent sizes of data regions: Y axis           SSTM has 26 points (J=16:41)           _expression_ has 56 points (J=01:56)   Any ideas? Am I doing something silly?   Cheers Pearse   From: Jian (Tony) Ma [mailto:tonyj.ma@xxxxxxxxx] Sent: Tuesday, 3 March 2015 5:11 PM To: Pearse Buchanan Cc: ferret_users@xxxxxxxx Subject: Re: [ferret_users] Changing SST regionally and combining the regions   use if then else   something like   let ssta1=if y gt 40 then sstN else sst let ssta2= if y lt -40 then sstS else ssta1 let ssta=if y le 40 and y ge -40 then sstM else ssta2   Tony   Sent from my iPhone On Mar 3, 2015, at 12:21 AM, Pearse Buchanan wrote: Hi all,   Very new to Ferret and I need some help.   Here is my data: yes? show data sstaC.nc      currently SET data sets:     2> ./sstaC.nc  (default) name     title                             I            J          K         L SST                                       1:64      1:56      1:12      ...   I = Longitude J = Latitude (~3.21° grids) K = Time (months)   I have a sea surface temperature (SST) grid that I want to alter. I want to do three things: 1.       Reduce SST north of 40N by 1.6 °C 2.       Reduce SST between 40S-40N by 0.7 °C 3.       Reduce SST south of 40S by 2.0 °C   For each of these operations I don’t want my temperature to go below -1.65C, and so I have been using the MAX function… (i.e., let sstSOUTH=max(sst[J=1:15S]-2, -1.65) let sstMID=max(sst[J=16:41]-0.7, -1.65) let sstNORTH=max(sst[J=42:56]-1.6, -1.65) )   This works fine. I am able to produce three separate variables: sstSOUTH, sstMID, sstNORTH. Each are modified as I like.   However, I do not know how to combine these together into the one .nc file and therefore recreate the world grid of sea surface temperatures.   I have been using: save/file=ZC_sstemp5d.nc sstSOUTH, sstMID, sstNORTH   And the datafile looks like this: yes? show data      currently SET data sets:     1> ./ZC_sstemp5d.nc  (default) name     title                                                     I            J          K         L SSTS     MAX(SST[J=1:15]-2,-1.65)            1:64      1:15      1:12      ... SSTM     MAX(SST[J=16:41]-0.7,-1.65)      1:64      1:26      1:12      ... SSTN     MAX(SST[J=42:56]-1.6,-1.65)       1:64      1:15      1:12      ...     Any advice would really really be appreciated. I’m sure it’s only a simple few commands that I’m missing.   Thanks to all, Pearse J. Buchanan PhD Candidate / CSIRO-UTAS Quantitative Marine Science Institute for Marine and Antarctic Studies (IMAS) University of Tasmania M +61 458701672       University of Tasmania Electronic Communications Policy (December, 2014). This email is confidential, and is for the intended recipient only. Access, disclosure, copying, distribution, or reliance on any of it by anyone outside the intended recipient organisation is prohibited and may be a criminal offence. Please delete if obtained in error and email confirmation to the sender. The views expressed in this email are not necessarily the views of the University of Tasmania, unless clearly intended otherwise.