pfmc-assessments / PacFIN.Utilities

R code to manipulate data from the PacFIN database for assessments
http://pfmc-assessments.github.io/PacFIN.Utilities
Other
7 stars 2 forks source link

getExpansion_2 turning years into pounds with single fleet model #4

Closed chantelwetzel-noaa closed 7 years ago

chantelwetzel-noaa commented 7 years ago

If Convert = TRUE for the getExpansion_2 code on line 138 where the catch weight in tons is converted to pounds is accidently multiplying the year column. I am working with a single fleet model where all areas and gears are grouped and the data frame for catches has two columns; year and catch. Currently, the indexing for converting to pounds is specified as 2:length(Catchgears) which with my model setup is 2:1 which results with the year column being multiplied by the pound conversion as well.

andi-stephens-NOAA commented 7 years ago

Thanks for this. How silly!

On my "TODO" list.

On Wed, Mar 8, 2017 at 8:20 AM, Chantel Wetzel notifications@github.com wrote:

If Convert = TRUE for the getExpansion_2 code on line 138 where the catch weight in tons is converted to pounds is accidently multiplying the year column. I am working with a single fleet model where all areas and gears are grouped and the data frame for catches has two columns; year and catch. Currently, the indexing for converting to pounds is specified as 2:length(Catchgears) which with my model setup is 2:1 which results with the year column being multiplied by the pound conversion as well.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/nwfsc-assess/PacFIN.Utilities/issues/4, or mute the thread https://github.com/notifications/unsubscribe-auth/AKdMBkQEaaiKNOmKY23JX0-eguIUnR6Wks5rjtU4gaJpZM4MW_KS .

chantelwetzel-noaa commented 7 years ago

I just looked at the correct and it is still not quite right. As example, if you have three fleets (aka Catchgears) with a Catch matrix with the dimensions of 4 x years (year, fleet1, fleet2, fleet3), the conversion loop will only convert the the second and third column because the indexing is done as:

Catch[ , 2:length(Catchgears)] * 2204 which would be Catch[ ,2:3] because Catchgears has a length of 3

What should be done in the code is:

Catch[ , 2:dim(Catch)[2]] * 2204

This correction will work for all fleet structures as long as the Catch matrix has year in the first column.

andi-stephens-NOAA commented 7 years ago

Thanks -- you're right. Alas, I was in a hurry.

On Fri, Apr 14, 2017 at 12:25 PM, Chantel Wetzel notifications@github.com wrote:

I just looked at the correct and it is still not quite right. As example, if you have three fleets (aka Catchgears) with a Catch matrix with the dimensions of 4 x years (year, fleet1, fleet2, fleet3), the conversion loop will only convert the the second and third column because the indexing is done as:

Catch[ , 2:length(Catchgears)] * 2204 which would be Catch[ ,2:3] because Catchgears has a length of 3

What should be done in the code is:

Catch[ , 2:dim(Catch)[2]] * 2204

This correction will work for all fleet structures as long as the Catch matrix has year in the first column.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/nwfsc-assess/PacFIN.Utilities/issues/4#issuecomment-294219293, or mute the thread https://github.com/notifications/unsubscribe-auth/AKdMBuytv8-5GvuxvaLq6u2E-lX0kJYwks5rv8gigaJpZM4MW_KS .

John-R-Wallace-NOAA commented 7 years ago

If year isn't always in the first column, I could show you in the off season how to code for that, as long as the year column name is somehow identifiable and uniquely labeled (e.g. year, Year, YEAR, Years, ...)

-John

On 4/14/2017 12:25 PM, Chantel Wetzel wrote:

I just looked at the correct and it is still not quite right. As example, if you have three fleets (aka Catchgears) with a Catch matrix with the dimensions of 4 x years (year, fleet1, fleet2, fleet3), the conversion loop will only convert the the second and third column because the indexing is done as:

Catch[ , 2:length(Catchgears)] * 2204 which would be Catch[ ,2:3] because Catchgears has a length of 3

What should be done in the code is:

Catch[ , 2:dim(Catch)[2]] * 2204

This correction will work for all fleet structures as long as the Catch matrix has year in the first column.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/nwfsc-assess/PacFIN.Utilities/issues/4#issuecomment-294219293, or mute the thread https://github.com/notifications/unsubscribe-auth/AGiX2VDI2-a4SnUFvfjLMigvKfdlIRdxks5rv8gigaJpZM4MW_KS.

andi-stephens-NOAA commented 7 years ago

Thanks, John -- I do know how to find the year column, but I also think it's entirely appropriate to demand that it be the first one!

--A.

On Fri, Apr 14, 2017 at 1:34 PM, John Wallace notifications@github.com wrote:

If year isn't always in the first column, I could show you in the off season how to code for that, as long as the year column name is somehow identifiable and uniquely labeled (e.g. year, Year, YEAR, Years, ...)

-John

On 4/14/2017 12:25 PM, Chantel Wetzel wrote:

I just looked at the correct and it is still not quite right. As example, if you have three fleets (aka Catchgears) with a Catch matrix with the dimensions of 4 x years (year, fleet1, fleet2, fleet3), the conversion loop will only convert the the second and third column because the indexing is done as:

Catch[ , 2:length(Catchgears)] * 2204 which would be Catch[ ,2:3] because Catchgears has a length of 3

What should be done in the code is:

Catch[ , 2:dim(Catch)[2]] * 2204

This correction will work for all fleet structures as long as the Catch matrix has year in the first column.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/nwfsc-assess/PacFIN.Utilities/issues/4#issuecomment- 294219293, or mute the thread https://github.com/notifications/unsubscribe-auth/AGiX2VDI2- a4SnUFvfjLMigvKfdlIRdxks5rv8gigaJpZM4MW_KS.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/nwfsc-assess/PacFIN.Utilities/issues/4#issuecomment-294231382, or mute the thread https://github.com/notifications/unsubscribe-auth/AKdMBrrC-p6MvMEzhU-qQ4-AooVVRq6vks5rv9g9gaJpZM4MW_KS .

andi-stephens-NOAA commented 7 years ago

Done!

On Fri, Apr 14, 2017 at 12:25 PM, Chantel Wetzel notifications@github.com wrote:

I just looked at the correct and it is still not quite right. As example, if you have three fleets (aka Catchgears) with a Catch matrix with the dimensions of 4 x years (year, fleet1, fleet2, fleet3), the conversion loop will only convert the the second and third column because the indexing is done as:

Catch[ , 2:length(Catchgears)] * 2204 which would be Catch[ ,2:3] because Catchgears has a length of 3

What should be done in the code is:

Catch[ , 2:dim(Catch)[2]] * 2204

This correction will work for all fleet structures as long as the Catch matrix has year in the first column.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/nwfsc-assess/PacFIN.Utilities/issues/4#issuecomment-294219293, or mute the thread https://github.com/notifications/unsubscribe-auth/AKdMBuytv8-5GvuxvaLq6u2E-lX0kJYwks5rv8gigaJpZM4MW_KS .